Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
my $s = "foo bar quux"; my $pattern = q(foo (.*?) quux); my $rep = q(foo quux $1); $s =~ s|$pattern|$rep}|; print "$s\n";I would like for this to print
foo quux barBut instead I get
foo quux $1How can I get the substitution operator to expand the $1 embedded in the replacement variable?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Back substitution expansion
by japhy (Canon) on Aug 20, 2001 at 03:52 UTC | |
|
Re: Back substitution expansion
by Monky Python (Scribe) on Aug 20, 2001 at 11:15 UTC |