my %hash = ("a" => undef, "b" => 0, "c" => 2); testing("a"); testing("b"); testing("c"); testing("d"); sub testing { my $key = shift; print "$key exists\n" if (exists $hash{$key}); print "the value of $key is defined\n" if (defined $hash{$key}); print "the value for $key is true" if ($hash{$key}); } #### a exists b exists the value of b is defined c exists the value of c is defined the value for c is true