[clue-tech] Fun perl script

Jeff Schroeder jeff at zingstudios.net
Tue Aug 1 09:42:22 MDT 2006


Mike asked:

> Since I've not done much in perl before, I'm a little confused as to
> where the source code of the webpage comes into play here.  Which
> variable would it be?  I ask because I'd like to run something like
> this against the source of the page:
>
> $source =~ s/Bush/Kerry/g;

The $_ variable contains the content of each line in the page source, so 
you can merely update the "else" block at the bottom to do whatever 
substitutions you'd like:

else {
  ($out = $_) =~ s/Bush/King George/g;
  $out =~ s/Windows/Linux/g;
  $out =~ s/this/that/g;
  print "$out\n";
}

My Perl's a little rusty, but I think that'll do it.

Have fun!
Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://cluedenver.org/pipermail/clue-tech/attachments/20060801/d2a7529e/attachment-0001.bin


More information about the clue-tech mailing list