#!/usr/bin/perl -w #################################################################################################### # # Program: mergelatex # # Function: Replaces all \include{file} commands with the actual file contents # # Author: Benjamin Bulheller # # Version: $Revision: 2945 $, $Date: 2008-04-28 17:13:10 +0100 (Mon, 28 Apr 2008) $ # # Date: September 2007 # #################################################################################################### use strict; # always use this!!! use Data::Dumper; # for easy printout of arrays and hashes use FindBin qw/$Bin/; # sets $Bin to the directory of the script use lib $Bin; # add the script's directory to the library path use lib "$ENV{HOME}/bin/perllib/"; # adds ~/bin/perllib to the library path use DebugPrint; # handy during debugging use ReadLatex; # to read LaTeX files use GetParameters; # to handle command line parameters ################################################################################################### # Configuration for GetParameters #################################################################################################### my $Parameters = { # create an anonymous hash o => "string*", }; my $Options = { # create an anonymous hash }; my $Help = "\n" . "Usage: mergelatex file.tex -o filemerged.tex\n" . "\n"; #################################################################################################### GetParameters ($Parameters, $Options, $Help); if (not $Options->{rest}) { print STDERR "\nERROR: No input file given!\n\n"; exit 1; } my $Infile = $Options->{rest}[0]; my @Content = ReadLatex ($Infile); open FILE, ">$Options->{o}" or die "ERROR: Could not write to $Options->{o}: $!"; print FILE join "", @Content; close FILE;