in reply to Re^5: In place search and replace with a hash
in thread In place search and replace with a hash
Well AnoMonk said "single quotes ... prevent variable interpolation" that's misleading.
maybe clearer with an example
DB<106> %h = (x => 0, '$1' => 1); => ("x", 0, "\$1", 1) DB<107> $s = 'axb' => "axb" DB<108> $s =~ s/(x)/'$1'/r; # no prevention => "a'x'b"
single quotes on the RHS of s/// never prevent interpolation.
Interpolation is the process to translate "$a $h{$b}" to $a . " " . $h{$b} at compile time.
But the keys of a hash-fetch are not interpolated they are executed, otherwise something like $h{$a$b} wouldn't cause a syntax error.
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: In place search and replace with a hash
by Athanasius (Archbishop) on Dec 28, 2014 at 08:26 UTC | |
by LanX (Saint) on Dec 28, 2014 at 13:27 UTC | |
|
Re^7: In place search and replace with a hash
by Anonymous Monk on Dec 28, 2014 at 08:51 UTC |