johnfl68: If $current->{'fileSet'}{'showAbbreviation'} could exist and be defined and yet be something other than a hash reference, it might be wise to add a test for hash-refitude to the other tests proposed by huck (attempting to dereference a non-hashref as a hash is fatal under strict refs, which you should, of course, have enabled :) (untested | since tested):
if (exists($current->{'fileSet'}->{'showAbbreviation'})
&& defined ($current->{'fileSet'}->{'showAbbreviation'})
&& 'HASH' eq ref($current->{'fileSet'}->{'showAbbreviation'})
&& ( scalar(keys %{$current->{'fileSet'}->{'showAbbreviation'}}) >0)
) {
...
}
Update: In fact, since ref returns the empty string for an undefined argument, the explicit defined test is not necessary, making the whole thing a bit less messy:
if (exists($current->{'fileSet'}->{'showAbbreviation'})
&& 'HASH' eq ref($current->{'fileSet'}->{'showAbbreviation'})
&& ( scalar(keys %{$current->{'fileSet'}->{'showAbbreviation'}}) >0)
) {
...
}
Give a man a fish: <%-{-{-{-<
In reply to Re^2: If hash not defined help
by AnomalousMonk
in thread If hash not defined help
by johnfl68
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |