That's wrong! Variable interpolation does easily dereference hashes and arrays (i.e. within strings and substitutes).
DB<114> $h={a=>42} => { a => 42 } DB<115> "$h->{a}" => 42
Though coderefs seem to be excluded.
DB<118> $sub=sub { "nope" } => sub { "???" } DB<119> "$sub->()" => "CODE(0xa5cc200)->()"
But the @{[...]} ("local eval") trick always helps where a general /e would cause too much harm.
DB<120> $_="X" => "X" DB<121> s/X/@{[ $sub->() ]}/ => 1 DB<122> $_ => "nope"
see also: s/RegEx/substitutions/: Variable interpolation and when to use /e - modifiers
Cheers Rolf
( addicted to the Perl Programming Language)
In reply to Re^2: Perl ignore arrow object operator in search/replace (s/searchregex/replacestring/)
by LanX
in thread Perl ignore arrow object operator in search/replace
by fouinix
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |