P is for Practical | |
PerlMonks |
perlfunc:deleteby gods (Initiate) |
on Aug 24, 1999 at 22:43 UTC ( [id://310]=perlfunc: print w/replies, xml ) | Need Help?? |
deleteSee the current Perl documentation for delete. Here is our local, out-dated (pre-5.6) version: delete - deletes a value from a hash
delete EXPR
Deletes the specified
The following deletes all the values of a hash:
foreach $key (keys %HASH) { delete $HASH{$key}; } And so does this:
delete @HASH{keys %HASH} (But both of these are slower than just assigning the empty list, or using undef().) Note that the EXPR can be arbitrarily complicated as long as the final operation is a hash element lookup or hash slice:
delete $ref->[$x][$y]{$key}; delete @{$ref->[$x][$y]}{$key1, $key2, @morekeys}; |
|