--- name: delete status: documented runtime: pp source: src/runtime/pp/aggregate.rs --- ```{index} single: delete; Perl built-in (pp runtime) ``` # delete ## Synopsis ```perl delete $hash{$key}; delete @hash{@keys}; # hash slice delete $array[$index]; my $val = delete $hash{$key}; # returns deleted value ``` ## Description 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`. ## See also exists, each, keys, splice