my @words = qw(john mary ted larry wendel); my %dict; @dict{@words} = undef; print "larry exists \n" if exists $dict{'larry'}; print "bill exists \n" if exists $dict{'bill'}; print "bill doesn't exist \n" unless exists $dict{'bill'};