in reply to hash refferences

The reference still points to the same place as %temporary, so changing one will also change the other. I suggest the following code:

foreach my $val (@variables) { my %temporary = ...; push @arrayOfHashes, \%temporary; };

%temporary is not a reference and hence you can't "lose" the reference to its data.