Four things:
- The way to get the value you want is with ${$h{'word1'}[0]}.
- If you'd have employed use strict, you'd notice that %h isn't yet defined when you try to grab $h{'word1'}. The value that $h{'word2}[0] currently contains is a reference to undef.
- You could have confirmed all of this by using Data::Dumper with print Dumper(\%h);.
- Why are you assigning a reference to an arrayref?
Proper way to do this would be to do:
my %h = (
'word1'=>[2,3],
'word2'=>[undef,3],
'word3'=>[1,2]
);
$h{word2}[0] = $h{word1};
print "@{$h{word2}[0]}\n";
__END__
antirice
The first rule of Perl club is - use Perl
The ith rule of Perl club is - follow rule i - 1 for i > 1