What is the difference between
if (defined $hash{$key}) { }
and
if (exists $hash{$key}) { }
When do I kno
This example shows the difference. In general defined works for any structure and exist is related to hashes.
my %hash=("1"=>undef);
print "exists:".exists($hash{"1"})."\n";
print "defined:".defined($hash{"1"})."\n";
The difference is small and not so obvious, so expect that people will mess with it.