my @a = qw(one two three four); my @b = qw(two four); my %b; @b{ @b } = (1)x@b; # one of many ways to create the hash for (@a) { unless ($b{$_}) { print "$_ is not in \@b\n" } }