From perlfunc:delete
The following (inefficiently) deletes all the values of %HASH: foreach $key (keys %HASH) { delete $HASH{$key}; } foreach $index (0 .. $#ARRAY) { delete $ARRAY[$index]; } And so do these: delete @HASH{keys %HASH}; delete @ARRAY[0 .. $#ARRAY]; But both of these are slower than just assigning the empty list or und +efining %HASH or @ARRAY: %HASH = (); # completely empty %HASH undef %HASH; # forget %HASH ever existed @ARRAY = (); # completely empty @ARRAY undef @ARRAY; # forget @ARRAY ever existed
Examine what is said, not who speaks.
The 7th Rule of perl club is -- pearl clubs are easily damaged. Use a diamond club instead.
In reply to Re: Garbage Collection on Hash delete
by BrowserUk
in thread Garbage Collection on Hash delete
by netoli
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |