> I have ~97 HTML documents that I need to strip the footer > (about 15 lines) from and > replace with a different block of text. The footer is > formatted differently in some of the > HTML files, but they all start with the line: > > <table border="0" width="100%" height="5%"> > > How can I replace everything after that particular line with > a custom block of text? Thanks.
Here's one way, you say the files are html so slurping shouldn't hurt: [untested - for principle demo only] #!/usr/bin/perl -w use strict; use File::Slurp; my $newhtml = '</table></body></html>'; my $split = '<table border="0" width="100%" height="5%">'; my @files = qw(index.html contact.html); # populate this by hand or automatially if you want my $count = 0; for(@files) { print "Starting $_ ..."; my $html = read_file($_); my ($firstpart) = split $split, $html; # may need to tweak around with this write_file($_, "$firstpart$split$newhtml"); print "Done!\n"; $count++; } print "\nFinished : $count files processed.\n"; > > -- > Andrew Gaffney > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>