defined checks the value of the variable, exists checks if it has been
previously declared/initialized. If it exists, plain and simple.
E.g.:
$hash{$key} = undef;
# various return values:
exists $hash{$key}; # true
defined $hash{$key}; # false
$hash{$key}; # false
$hash{$key} = 0;
# various return values:
exists $hash{$key}; # true
defined $hash{$key}; # true
$hash{$key}; # false
exists $hash{$foo}; # false
No comments:
Post a Comment