pysome has asked for the wisdom of the Perl Monks concerning the following question:
How to eval an array element in regex's substitution ?
Dear All,
I wanna get "Hello zy" in following code. I try to add /e and /ee, all they can't work.
Dear All,
I wanna get "Hello zy" in following code. I try to add /e and /ee, all they can't work.
Pls give me a hand. THX.my $s = 'Hello [2][1]'; my @a =('x','y','z'); my $replace ='$a'; $s =~ s/(\[\d{1,2}\])/$replace\1/g; ## only output : Hello $ +a[2]$a[1] print $s;
Regards
-Pysome
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How to eval an array element in regex's substitution
by ikegami (Patriarch) on Oct 27, 2010 at 03:36 UTC | |
by pysome (Scribe) on Oct 27, 2010 at 04:48 UTC | |
by ikegami (Patriarch) on Oct 27, 2010 at 06:48 UTC | |
Re: How to eval an array element in regex's substitution
by aquarium (Curate) on Oct 27, 2010 at 04:23 UTC | |
by aquarium (Curate) on Oct 27, 2010 at 05:40 UTC | |
by Anonymous Monk on Oct 27, 2010 at 06:23 UTC | |
by aquarium (Curate) on Oct 27, 2010 at 21:52 UTC |
Back to
Seekers of Perl Wisdom