upaksh has asked for the wisdom of the Perl Monks concerning the following question:
my %replace = ('111'=>bar, '222'=>world, '333'=>perl); my $find = join "|", sort keys %replace; my $str = "f111,f222,f333"; $str =~ s/f(0-9)/$replace{$1}/g;
I am expecting the output as "bar, world, perl". but instead the output is "11,22,33". neone suggest me whts wrong pls?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: problem with substitute in regexp
by moritz (Cardinal) on Nov 10, 2011 at 08:45 UTC | |
|
Re: problem with substitute in regexp
by ansh batra (Friar) on Nov 10, 2011 at 09:01 UTC | |
by roboticus (Chancellor) on Nov 10, 2011 at 11:37 UTC | |
by ansh batra (Friar) on Nov 10, 2011 at 15:38 UTC | |
by roboticus (Chancellor) on Nov 10, 2011 at 15:53 UTC | |
by bluray (Sexton) on Nov 11, 2011 at 16:36 UTC | |
|
Re: problem with substitute in regexp
by AnomalousMonk (Archbishop) on Nov 10, 2011 at 16:19 UTC | |
|
Re: problem with substitute in regexp
by upaksh (Novice) on Nov 11, 2011 at 11:28 UTC |