{ my $array_ref = []; for(1 ... 10) { my $hash_ref = { foo => foo, bar => bar }; push(@{$array_ref}, $hash_ref); } } # $array_ref is freed here.