perl -MData::Dumper=Dumper -le '%hash = ( a=>3, b=>4, c=>1, d => 7 ); @ary = qw(b c); @nhash{@ary} = delete @hash{@ary}; print Dumper \%hash; print Dumper \%nhash;' $VAR1 = { 'a' => 3, 'd' => 7 }; $VAR1 = { 'c' => 1, 'b' => 4 };