Stegalex has asked for the wisdom of the Perl Monks concerning the following question:
I know this is probably a stupid question but that's only because I am a stupid person. Sorry if my question makes you groan with disgust. I like chicken.#!/usr/bin/perl -w $regex = "s/foo/bar/g"; $compiled = qr/$regex/; # program works the same # whether I do this or not $string = "foo fru foodyfoo"; $string =~ $compiled; print "$string\n"; # no substitution! $string is still # "foo fru foodyfoo" instead of # "bar fru bardybar".
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Compiling regular expressions to perform substitution
by broquaint (Abbot) on Apr 11, 2002 at 13:11 UTC | |
by Stegalex (Chaplain) on Apr 11, 2002 at 13:20 UTC | |
|
It doesn't mean what you think it means
by Fletch (Bishop) on Apr 11, 2002 at 13:14 UTC | |
by Stegalex (Chaplain) on Apr 11, 2002 at 15:05 UTC |