in reply to One-shot code critique

For one, you don't need both of those patterns at the top, if you just replace
$text =~ s/$target/$replace/; $text =~ s/$target2/$replace/;
with
$text =~ s/$target/$replace/i; # Case-insensitive

Second, I'd look at letting Perl's -i and -p flags do all your editing in place for you. It takes care of all the globbing, the reading the file, etc etc etc.

For instance, your code could simply be (rough and untested):

#!perl -i~ -p BEGIN { $/ = undef; $target = blah blah blah; $replace = blah blah blah; } s/$target/$replace/ig;
And you'd just call it as:
myprog.pl *.asp

Perl has some very powerful, very common idioms to do this most common of text transformations. Take advantage of them when you can.

xoxo,
Andy
--
<megaphone> Throw down the gun and tiara and come out of the float! </megaphone>

Replies are listed 'Best First'.
Re: Use Perl's in-place file-handling capabilities
by patgas (Friar) on Sep 28, 2001 at 20:50 UTC

    I originally tried using the case-insensitive substitution, but it didn't seem to catch all the files. The only other difference I could find in the files are the " "s surrounding the body background color, but I wasn't 100% sure if my regex would match if it had the quotes or not. This was a one-shot deal, and I needed it to work as quickly as possible, even at the expense of researching the perfect regex.

    "We're experiencing some Godzilla-related turbulence..."