in reply to Common Perl Pitfalls
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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Common Perl Pitfalls
by Joe_ (Beadle) on May 14, 2012 at 22:21 UTC |