[forwarded submission from a non-member address -- rjk]


From: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
Date: Tue, 20 Mar 2001 00:46:32 -0500 (EST)
Subject: Re: [Boston.pm] multiline search and replace
To: "Matthew J. Brooks" <[EMAIL PROTECTED]>
cc: Boston Perl Mongers <[EMAIL PROTECTED]>

sub blah {
  my $dir = shift;
  opendir (DIR, "$dir") or die "can't open $dir";
  foreach my $file (readdir (DIR)) {
    next if ($file =~ /\.|\.\./);
    if (-d $file) {
      blah ($file);
    }
    if ($file =~ /\.html*/) {
      open (FILE, "$_") or die "can't open $file";
      my $html_file = join ("",<FILE>);
      $html_file =
        s/regex_that_matches_java_script/your_replacement_a_href/g;
      close (FILE);
      open (FILE,">$file"); #open for reading
      print FILE $html_file;
      close (FILE);
    } 
  }
}


eh, this works i think... well the logic does, i didn't compile it. you
could tinker with it and see what you get. good luck. it's not going to be
efficient. all i did was slurp up the whole file to do one swap
statment. it puts it all into memory like in my xml routine. i am changing
this very soon in it because it's a bad idea but for a quick html file
hacker it works great. i'll be posting the xml_routine.pl that i presented
very soon when i've finished changing some things that need tweaking and
it's ready for the eyes of the masses.

-mike

Reply via email to