If I have a variable, $bar
, which is equal to string "foo"
and $foo
is equal to 0xdead
, how can I get $foo
's value while I only have the the string for the variable name?
Essentially, I want to do a kind of pointer indirection on the global namespace or a hash lookup on the global namespace.
The following didn't work:
perl -e 'my $foo=0xdead; my $bar ="foo"; print ${$bar}."\n";'
It only prints the newline.