symbolic-references

How can I use a variable as a variable name in Perl?

I need to achieve the following in perl printmsg(@val1, $msg1) if @val1; printmsg(@val2, $msg2) if @val2; printmsg(@val3, $msg3) if @val3; printmsg(@val4, $msg4) if @val4; printmsg(@val5, $msg5) if @val5; printmsg(@val6, $msg6) if @val6; So i wrote the following snippet for(my $i=1; $i < 6; $i++ ) { printmsg(@val$i, $msg$i) if @v...

How can I use the value of a variable as a variable name in Perl?

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...