#!/usr/bin/perl use Data::Dumper; my %h; { local $h{key} = 'blah'; # even "local $h{key};" will do # inititialization is only for clarity } print Dumper \%h; #### $VAR1 = { 'key' => undef }; #### $VAR1 = {}; #### # ... my %h; # ... my @local_keys = qw/foo bar baz/; my @inexistent = grep {! exists $h{$_}} @local_keys; { local @h{@local_keys}; # ... } delete @h{@inexistent}; # ...