almaric has asked for the wisdom of the Perl Monks concerning the following question:
still "only" a regexp question:
I have
which prints$a='abab'; $b='a(.)'; $c='a$1'; print "\$a $a\n"; print "\$b $b\n"; print "\$c $c\n"; $a =~ s/$b/$c/g ; # so this is s/a(.)/a$1/g print "\$a $a\n";
What I wanted/expected was the last line to be$a abab $b a(.) $c a$1 $a a$1a$1
It's clear, after $c is evaluated to a$1 $1 isn't further evaluated to the content of the matching braces in the regexp.$a abab
How to change the above code so that the output is my expected one? Is it possible to combine this two different evaluations? Thanks for any help.
regards,
almaric
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: regexp $1 in a variable
by Enlil (Parson) on Mar 02, 2004 at 03:51 UTC | |
|
Re: regexp $1 in a variable
by Stevie-O (Friar) on Mar 02, 2004 at 02:05 UTC | |
by mawe (Hermit) on Mar 02, 2004 at 07:14 UTC | |
|
Re: regexp $1 in a variable
by Roger (Parson) on Mar 02, 2004 at 00:36 UTC | |
|
Re: regexp $1 in a variable
by esskar (Deacon) on Mar 02, 2004 at 00:29 UTC |