in reply to Re: Hashing it out: defined? exists?
in thread Hashing it out: defined? exists?

Just to add a little bit for the OP to understand:

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}); }

This prints:

a exists b exists the value of b is defined c exists the value of c is defined the value for c is true