Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

delete

Removes the specified element(s) from a hash or array.

For hashes, removes the key-value pair and returns the deleted value (or undef if the key did not exist). Read-only hashes (such as %!) and Hash::Util-restricted hashes reject deletion with an error. For arrays, sets the element to undef without changing the array size; use splice to actually shrink.

Stash-backed hashes (accessed via %{"Package::"}) route the deletion through the PackageRegistry so the symbol is removed from the live stash, not just from the snapshot Hv.

Synopsis

delete $hash{$key};
delete @hash{@keys};               # hash slice
delete $array[$index];
my $val = delete $hash{$key};       # returns deleted value

See Also

exists, each, keys, splice