Thanks for the reply Mike.

The problem seems more to do with the regex than anything. I need to search
for something like...

<script LANGUAGE="JAVASCRIPT">
<!--
VendorSite= "Companycom";
VendorPage= "CompanyMail";
VendorWidth= 468;
VendorHeight= 60;
VendorPrintTag= true;
VendorNewAd= true;
VendorLoaded= false;
VendorVersion= 3.2;
file://-->
</script>
<script
SRC="http://Vendor.com/ads/" LANGUAGE="JAVASCRIPT"></script>
<script
LANGUAGE="JAVASCRIPT">
<!--
if (VendorLoaded) VendorDeliverAd();
file://-->
</script>
<NOSCRIPT> <a target="_top"
HREF="http://Vendor.com/server/click/Compancom/CompanyMail/123"><img
SRC="http://Vendor.com/server/ad/Companycom/CompanyMail/123" border="0"
width="468" height="60"></a>
</NOSCRIPT>


...in the html files and replace it with:

<IMG SRC="http://www.Company.com/ads/default.gif'>


The Vendor here dropped their services on Company early (basically as soon
as they found out their contract was not going to be renewed) and now
Company's web site has public service ads being fed to it. They want to have
default.gif displayed until they come up with an internal solution for
banner rotation (that probably will end up in my lap too). Either way,
they've got a lost revenue issue, but without this change they also have a
content control issue.


----- Original Message -----
From: <[EMAIL PROTECTED]>
To: "Matthew J. Brooks" <[EMAIL PROTECTED]>
Cc: "Boston Perl Mongers" <[EMAIL PROTECTED]>
Sent: Tuesday, March 20, 2001 12:46 AM
Subject: Re: [Boston.pm] multiline search and replace


> 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