http://qs321.pair.com?node_id=967968


in reply to Common Perl Pitfalls

while($string=~ m/reg(ex)/) { $string=~ s/$1/ister/; }

That frightens me a bit. Your substitution replaces the first occurance "ex" with "ister" in the string, no matter whether "ex" is part of "regex" or something else:

my $string = "Sometimes there are extra effects you didn't foresee whe +n using a regex."; while($string=~ m/reg(ex)/) { $string=~ s/$1/ister/; } print $string;

Output:

Sometimes there are istertra effects you didn't foresee when using a r +egister.

Istertra?