in reply to references--hard vs anonymous operational weirdness

As mentioned by both hipowls and Fletch, the issue is likely that your @array is declared outside of the loop. If you wanted to prove to yourself that a new array ref is being created, or that an existing one is being reused, you can examine the memory address by printing the reference (see perldsc). The following example illustrates the difference between an array declared outside the loop and one that is declared on every iteration.

use strict; use warnings; my %hash; my $same_array = []; for( 1 .. 3 ) { $hash{$_}{same} = $same_array; $hash{$_}{new} = []; print "$_: $hash{$_}{same} vs $hash{$_}{new}\n"; }
Output:
1: ARRAY(0x34f88) vs ARRAY(0x35d50) 2: ARRAY(0x34f88) vs ARRAY(0x1854e88) 3: ARRAY(0x34f88) vs ARRAY(0x1854e34)