The following works are just fine for me according to perl 5.10 and 5.14:
use strict; use Data::Dumper; my @array= qw(foo 42 bar); my %hash; @{ $hash{key} } = @array; $hash{key} = [ @array ];
(your order may vary):
$VAR1 = { 'key' => [ 'foo', '42', 'bar' ] }; $VAR2 = '42';
I prefer the syntax @{ $hash{key} } because you can click / place it, i.e.
push @{ $hash{key} }, "value";
which is surprisingly convenient (for me anyway)
In addition, with this syntax, you copy the array, and not just add a reference to it, that is, you can change the original array without affecting the hash
source share