c:\@Work\Perl\monks>perl -wMstrict -MData::Dumper -le "sub foo { ;; my @this_array; my %this_hash; ;; foreach my $something (0 .. 4) { ;; push(@this_array, $something); ;; my $key = $something + 1000; $this_hash{$key} = \@this_array; ;; @this_array = (); ;; } ;; return(\%this_hash); } ;; my $hash_ref = foo(); print Dumper $hash_ref; " $VAR1 = { '1002' => [], '1001' => $VAR1->{'1002'}, '1004' => $VAR1->{'1002'}, '1000' => $VAR1->{'1002'}, '1003' => $VAR1->{'1002'} }; #### c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "sub foo { ;; my %this_hash; ;; foreach my $something (0 .. 4) { ;; my @this_array; push(@this_array, $something); ;; my $key = $something + 1000; $this_hash{$key} = \@this_array; ;; } ;; return(\%this_hash); } ;; my $hash_ref = foo(); dd $hash_ref; " { 1000 => [0], 1001 => [1], 1002 => [2], 1003 => [3], 1004 => [4] }