use warnings; use strict; my @foo = qw/tom steve bill roger bob/; my %bar = (roger => 99, steve => 56, ted => 88, tom => 54); for my $name (@foo) { print "$name : $bar{$name} \n" if exists $bar{$name}; }