if (exists ($hash{$word[-1]})) { print("$word[-1] OK\n"); } else { print("$word[-1] isn't in the hash\n"); }