I was wondering why this array that I am attempting to create at line 21
seems to be empty. If I want to put chunks separated by <p align="center">
into the array, how could I do this differently to make it work?

######################################################################

#!C:\Perl\bin\perl.exe -w

$/ = ''; # slurp in paragraph mode
my $inputfile = 'C:\path\to\file.htm';
my $outputfile = 'C:\path\to\OUT.html';

open(INFILE,"<$inputfile") or die "Could not open IN: $! \n";
open(OUTFILE,">$outputfile") or die "Could not open OUT: $! \n";

my @sections = ();

while(<INFILE>) {
 chomp;
 $_ =~ s/\r{3,}/\r/g; # change multiple carriage returns to single \r
 $_ =~ s/\n{3,}/\n/g; # change multiple newlines to \n (may not be
necessary)
 $_ =~ s/<\/*html>//g;        # these
 $_ =~ s/<\/*head>//g;        # are
 $_ =~ s/<\/*title>//g;       # pretty
 $_ =~ s/<\/*body.*?>//g;     # obvious
 $_ =~ s/(<br wp=.*?>)+//g;   # get rid of weird WordPerfect schneck
 @sections = split /<p align=\"center\">/, $_; # these are the chunks I want
 print OUTFILE $_;
}

print OUTFILE "\n\n"; # add a couple of newlines to separate results

foreach my $section(@sections) {
 chomp($section);
 print OUTFILE "$section \n\n\n"; # why is this printing nothing?
}

close(OUTFILE);
close(INFILE);
1;




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to