Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks! I've got a perl scripts that runs perl today to clean up a bunch of HTML files. It's a huge resource hog. I was wondering if there might be a better way to do what I'm doing? Here's my code:
my $call_dir = "Bing/1Parsed/Html3"; my $contents_of_file = 1; #my $tidy = HTML::Tidy->new(); my $tidy = HTML::Tidy->new({ tidy_mark => 1, #output_xhtml => 1, # yes #output_xhtml => 1, # yes add_xml_decl => 1, # no wrap => 76, error_file => errs.txt, char_encoding => utf8, indent_cdata => 1, clean => 1, fix_bad_comments =>1 }); my @files = glob "$call_dir/*.html"; printf "Got %d files\n", scalar @files; for my $file (@files) { open my $in_fh, '<', $file or die "Could not open $file : $!"; my $contents_of_file = do { local $/;<$in_fh> }; close $in_fh; $tidy->parse( $file, $contents_of_file ); open OUT,'>',$file or die "$!"; print OUT $tidy->clean( $file, $contents_of_file ); print "cleaning" . $file; for my $message ( $tidy->messages ) { #print $message->as_string; }
Thanks in advance for any help and or insight!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: HTML::Tidy - uses up RAM at crazy rate
by graff (Chancellor) on Mar 13, 2016 at 03:42 UTC | |
by Anonymous Monk on Mar 13, 2016 at 18:42 UTC | |
by graff (Chancellor) on Mar 13, 2016 at 23:06 UTC | |
by Anonymous Monk on Mar 14, 2016 at 04:30 UTC | |
by Anonymous Monk on Mar 14, 2016 at 06:36 UTC | |
by graff (Chancellor) on Mar 16, 2016 at 05:04 UTC | |
by Anonymous Monk on Mar 14, 2016 at 04:34 UTC |