markkawika has asked for the wisdom of the Perl Monks concerning the following question:
where $str, $match, and $repl are strings fed to me by my user. Ignoring the security implications of this (I know there are plenty), I cannot get perl to recognize "\1" or "$1" sequences in the $repl variable.$str =~ s/$match/$repl/;
For example, if $str contains "abc", $match contains "(a)(.)", and $repl contains "\2\1", $str ends up containing "\2\1c" instead of "bac", as intended.
Is there any way to force s/// to process this like I want?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do you get s/// to look inside variables in the replacement string?
by almut (Canon) on Nov 28, 2007 at 01:05 UTC | |
by markkawika (Monk) on Nov 28, 2007 at 01:40 UTC | |
|
Re: How do you get s/// to look inside variables in the replacement string?
by graff (Chancellor) on Nov 28, 2007 at 01:40 UTC |