in reply to Re^2: In place search and replace with a hash
in thread In place search and replace with a hash
It works with strings too :)
output:use 5.020; use warnings; my %h = ( foo => 1, bar => 2 ); $_ = 'foobar'; s/(foo)/$h{'$1'}/; say $_; $_ = 'foobar'; s/(foo)/$h{$1}/; say $_; my $foo = 'foo'; say "$h{'$foo'}bar";
Use of uninitialized value $h{"$1"} in substitution iterator at extr.p +l line 7. bar 1bar Use of uninitialized value $h{"$foo"} in concatenation (.) or string a +t extr.pl line 15. bar
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: In place search and replace with a hash
by LanX (Saint) on Dec 28, 2014 at 03:08 UTC |