Reputation: 53
I have following piece of code
$var1 = 10;
@arr = (1, \$var1, 3);
print "var1= $$arr[1] \n";
This is not printing value 10, is this syntax $$arr[1]
correct?
using additional variable i was able to print the value
$r = $var[1];
print "var1 = $$r\n";
Upvotes: 1
Views: 79
Reputation: 385897
If it's $NAME
if you have the name, it's $BLOCK
if you have a reference. So,
${ $arr[1] }
or (5.24+)
$arr[1]->$*
or (5.20+)
use experimental qw( postderef );
$arr[1]->$*
References:
Upvotes: 5