1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- use strict;
- if ( $#ARGV !=1 ) {
- die "Usage: $0 xml_infile xml_outfile\n";
- }
- my $infile = shift;
- die "Can't find file \"$infile\""
- unless -f $infile;
- if (! -r $infile) {
- die "Can't read input $infile\n";
- }
- open( INFILE,"<$infile" ) or
- die "Can't input $infile $!";
- my $outfile = shift;
- open( OUTFILE,">$outfile" ) or
- die "Can't output $outfile $! for writing";
- my ($prev, $curr, $str);
- $prev = ''; $curr = '';
- while ( <INFILE> ) {
- print OUTFILE $prev;
- $prev = $curr;
- $curr = $_;
- $str = '';
- if ( $prev =~ /<programlisting>$|<screen>$/ ) {
- chomp $prev;
- $curr = join( '', $prev, "<![CDATA[", $curr );
- $prev = '';
- next;
- }
- elsif ( $curr =~ /<\/programlisting>|<\/screen>/ ) {
- chomp $prev;
- $curr = join( '', $prev, "]]>", $curr );
- $prev = '';
- next;
- }
- }
- print OUTFILE $curr;
- close INFILE;
- close OUTFILE;
- exit;
|