Chris@4: #!/usr/bin/perl -w Chris@4: # Chris@4: # ------------------------------------------------------------------ Chris@4: # This file is part of bzip2/libbzip2, a program and library for Chris@4: # lossless, block-sorting data compression. Chris@4: # Chris@4: # bzip2/libbzip2 version 1.0.6 of 6 September 2010 Chris@4: # Copyright (C) 1996-2010 Julian Seward Chris@4: # Chris@4: # Please read the WARNING, DISCLAIMER and PATENTS sections in the Chris@4: # README file. Chris@4: # Chris@4: # This program is released under the terms of the license contained Chris@4: # in the file LICENSE. Chris@4: # ------------------------------------------------------------------ Chris@4: # Chris@4: use strict; Chris@4: Chris@4: # get command line values: Chris@4: if ( $#ARGV !=1 ) { Chris@4: die "Usage: $0 xml_infile xml_outfile\n"; Chris@4: } Chris@4: Chris@4: my $infile = shift; Chris@4: # check infile exists Chris@4: die "Can't find file \"$infile\"" Chris@4: unless -f $infile; Chris@4: # check we can read infile Chris@4: if (! -r $infile) { Chris@4: die "Can't read input $infile\n"; Chris@4: } Chris@4: # check we can open infile Chris@4: open( INFILE,"<$infile" ) or Chris@4: die "Can't input $infile $!"; Chris@4: Chris@4: #my $outfile = 'fmt-manual.xml'; Chris@4: my $outfile = shift; Chris@4: #print "Infile: $infile, Outfile: $outfile\n"; Chris@4: # check we can write to outfile Chris@4: open( OUTFILE,">$outfile" ) or Chris@4: die "Can't output $outfile $! for writing"; Chris@4: Chris@4: my ($prev, $curr, $str); Chris@4: $prev = ''; $curr = ''; Chris@4: while ( ) { Chris@4: Chris@4: print OUTFILE $prev; Chris@4: $prev = $curr; Chris@4: $curr = $_; Chris@4: $str = ''; Chris@4: Chris@4: if ( $prev =~ /$|$/ ) { Chris@4: chomp $prev; Chris@4: $curr = join( '', $prev, "|<\/screen>/ ) { Chris@4: chomp $prev; Chris@4: $curr = join( '', $prev, "]]>", $curr ); Chris@4: $prev = ''; Chris@4: next; Chris@4: } Chris@4: } Chris@4: print OUTFILE $curr; Chris@4: close INFILE; Chris@4: close OUTFILE; Chris@4: exit;