use strict;
use warnings;
use Data::Dumper;
my %hash = ( a => 1, b => 0, c => undef, e => 1, f => 0, g => undef );
my @interesting_keys = qw( a b c d );
my %small_hash = map {
($hash{$_}) ? ($_ => $hash{$_}) : ()
} @interesting_keys;
print Dumper(\%small_hash);
####
my %small_hash =
map { $_ => $hash{$_} }
grep { $hash{$_} }
@interesting_keys;
####
$VAR1 = {
'a' => 1
};