my @array = qw/sarah john/; my %hash = ( sarah => 19, john => 25, emma => 22, ); print "$_: $hash{$_}\n" for grep exists $hash{$_}, @array; __output__ sarah: 19 john: 25