nafion112 has asked for the wisdom of the Perl Monks concerning the following question:
Hi All!
I am trying to do a regex substitiution that is contained in a variable. For example, if I have:
$substitution = 's/this/that/';I would like to do something like:
$candidate =~ ($substitution);or
$candidate =~ s/($substitution)/;or something like that. Both of those are obviously wrong, but you get the idea. I've been fooling around with every little syntax modification I can think of and nothing seems to work. Might there be a better way to go about this? (I cannot change the fact that I am given the actual substitution regex, complete with delimiters, in a scalar variable...)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Substitution with regexes in variables
by ikegami (Patriarch) on Nov 15, 2009 at 00:07 UTC | |
by JadeNB (Chaplain) on Nov 15, 2009 at 07:38 UTC | |
by ikegami (Patriarch) on Nov 15, 2009 at 07:56 UTC | |
by JadeNB (Chaplain) on Nov 15, 2009 at 07:59 UTC | |
|
Re: Substitution with regexes in variables
by AnomalousMonk (Archbishop) on Nov 14, 2009 at 23:50 UTC |