APM: Regular expression with double variable substitution
Evan Harris
eharris at puremagic.com
Fri Jan 6 12:04:55 PST 2006
Is there any way to make perl re-interpret the contents of a variable that
is used as a substitution part of a regex? I thought that the /e modifier
would do this, but it doesn't seem to work.
For example:
$s = '$1 - $2';
$t = '34:56';
$t =~ s/(\d+):(\d+)/$s/e;
After this, $t is equal to '$1 - $2', rather than the desired '34 - 56'.
I think it may be possible by using an eval, but I don't want the power (and
the danger) of allowing any perl code, I just want to fill in nested
variables.
Evan
More information about the Austin
mailing list