5 # addcorr.pl [inputCorrections HTMLfile(s)]
7 # Combines the operations of corrtohtml.pl, sortcorrhtml.pl, and
8 # mergecorrhtml.pl into one simple command line. Anything that needs
9 # to do anything more complex than this should use the three utilities
12 # The book code will be obtained from the input HTML filename. E.g.
13 # 01fftd-changes.html provides the book code 01fftd. If for some reason
14 # the input HTML filename doesn't hold the book code in the first
15 # characters before the hyphen, use the three separate utilities.
17 # Anything that isn't specified on the command line will be prompted for.
19 # This program uses the most used pattern of using these three utilities.
21 # corrtohtml.pl -v -b bookCode inputCorrections
22 # | sortcorrhtml.pl -v -s -b bookCode
23 # | mergecorrhtml.pl inputHTML
26 # This utility also has the side effect of creating a backup copy of
29 ######################################################################
32 my $programName = "addcorr";
33 my $usage = "$programName [inputCorrections HTMLfile(s)]\n";
35 unless( -d $ENV{AONPATH} ) { die "\$AONPATH environment variable doesn't point to a directory"; }
37 my $convert = $ENV{AONPATH} . "/bin/corrtohtml.pl";
38 die( "Cannot find executable file \"$convert\"" ) unless( -x $convert );
39 my $sort = $ENV{AONPATH} . "/bin/sortcorrhtml.pl";
40 die( "Cannot find executable file \"$sort\"" ) unless( -x $sort );
41 my $merge = $ENV{AONPATH} . "/bin/mergecorrhtml.pl";
42 die( "Cannot find executable file \"$merge\"" ) unless( -x $merge );
44 die( "Cannot find executable file \"$copy\"" ) unless( -x $copy );
46 my $optsProcessed = 0;
94 ######################################################################
96 while( $#ARGV > -1 && not $optsProcessed ) {
97 my $commandLineItem = shift @ARGV;
98 if( $commandLineItem eq "--help" ) {
99 print $usage and exit;
101 elsif( $commandLineItem eq "-v" ) {
105 unshift @ARGV, $commandLineItem;
111 $inCorr = shift @ARGV or die "Couldn't get input corrections\n$usage";
112 $inHTML = shift @ARGV or die "Couldn't get input HTML\n$usage";
115 while( $inCorr eq "" ) {
116 print "Corrections File: ";
120 while( $inHTML eq "" ) {
121 print "Input HTML File: ";
127 while( $inHTML ne "" ) {
128 die( "Cannot find corrections file \"$inCorr\"" ) unless( -f $inCorr );
129 die( "Cannot read corrections file \"$inCorr\"" ) unless( -r $inCorr );
130 die( "Cannot find HTML file \"$inHTML\"" ) unless( -f $inHTML );
131 die( "Cannot read HTML file \"$inHTML\"" ) unless( -r $inHTML );
132 die( "Cannot write to HTML file \"$inHTML\"" ) if( -f $inHTML && ! -w $inHTML );
135 $bookCode =~ s{^([[:lower:][:digit:]]+)-.*$}{$1};
136 die( "Unknown book code \"$bookCode\" (obtained from \"$inHTML\")" ) unless( exists $books{ $bookCode } );
138 print "Bookcode: $bookCode\n" if( $verbose );
139 # leave backup untouched while putting output in original filename
140 print qx{$copy $inHTML $inHTML.backup};
142 $inHTML = "$inHTML.backup";
144 print qx{ $convert -v -b $bookCode $inCorr | $sort -v -s -b $bookCode | $merge $inHTML >$outHTML };
147 $inHTML = shift @ARGV if( $#ARGV > -1 );