in reply to Common Perl Pitfalls
Of course if you had meant the string $to_replace is an actual regex to match against, you're better off using the qr operator:I don't get this point. You started off that section with:
and doomed this catastrophically unsafe, because $to_replace may actually contain characters that have a special meaning.$to_replace='some_string'; $my_string=~ s/$to_replace/$better_data/;
But if $to_replace is actually a regexp, the premises is gone -- any special characters are intentional. In fact, it's quite fine in that case to use the above.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Common Perl Pitfalls
by Joe_ (Beadle) on Apr 10, 2012 at 18:21 UTC | |
by JavaFan (Canon) on Apr 10, 2012 at 21:29 UTC | |
by Joe_ (Beadle) on Apr 10, 2012 at 22:10 UTC | |
by JavaFan (Canon) on Apr 10, 2012 at 23:19 UTC | |
by Joe_ (Beadle) on Apr 10, 2012 at 23:43 UTC | |
| |
by Jenda (Abbot) on Apr 11, 2012 at 16:23 UTC | |
|