%h1=( 1=>"one", 2 => "two", 3 => "three", 4 => "four"); @set=(1, 3, 5, 7); my %h2; $h2{$_} = $h1{$_} for grep exists $h1{$_}, @set;