in reply to Re: Simplify parsing a file
in thread Simplify parsing a file

My new source is below. This works fine on HTML, but not so great on the JSP. I'll get to work on that part myself. Thanks to everyone!
use strict; use HTML::TokeParser::Simple; if($#ARGV < 0){ die "You did not specify any files to process! : $@\n"; } foreach my $infname (@ARGV) { my $outfname = $infname.".txt"; my $inputtxt = HTML::TokeParser::Simple->new($infname); my $outputtxt = ""; #this section removes the code while(my $token = $inputtxt->get_token){ next unless $token->is_text; $outputtxt.= $token->as_is; } #this section removes whitespace $outputtxt =~ s/&nbsp;/ /g; #HTML special space char $outputtxt =~ s/\s\s\s//mg; #tabs (mostly) and newlines open (OUTPUT, ">>$outfname") or die "$outfname could not be opened +.: $@ *_* $!\n"; print OUTPUT $outputtxt; close $infname; close $outfname; }