Charles K. Clarkson wrote:
Dan Muey <[EMAIL PROTECTED]> wrote:
: : Andrew Gaffney <[EMAIL PROTECTED]> wrote:
:
: > 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,

    If your server is SSI (or ASP) enabled, you might
consider replacing the existing footer with an included
file. That way you will only have to change one file in
the future. And it can be adjusted more often.

I am already using mod_perl with Apache in Linux to run most of my perl CGI scripts. I have yet to actually re-write them in mod_perl. I'm just using Apache::Registry. I'm thinking about using HTML::Mason to do this kind of thing already. Its still in the planning stages for now, but it is an option.


--
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>




Reply via email to