in reply to deleteing references
[] creates a new empty array and returns a reference to it.
If your goal was simply to empty the array, you could use @$array_ref = ();
If your goal was to free the array and the reference, you could use undef $array_ref; or let the reference fall out of scope.
{ my $array_ref = []; for(1 ... 10) { my $hash_ref = { foo => foo, bar => bar }; push(@{$array_ref}, $hash_ref); } } # $array_ref is freed here.
|
|---|