G'day smartyollie,
There's a semantic issue here. Hashes consist of zero or more pairs of keys and values: talking about a "null hash value" probably isn't what you meant.
I suspect, from the code you've posted, you meant a hash without any key/value pairs. If so, keys will probably do what you want. Here's an example:
#!/usr/bin/env perl -l use strict; use warnings; my %multi = (empty => {}, data => { a => 1 }); for my $key (keys %multi) { if (keys %{$multi{$key}}) { print "Data found in $key"; } else { print "Data not found in $key"; } }
Output:
$ pm_1129100_complex_hash_check.pl Data found in data Data not found in empty
If I haven't guessed correctly, please read "Checking Variable for Not Null". This was posted last week and contains a discussion about NULL not being a Perl concept, per se. Having done that, please reword your question, replacing "null" with undefined, zero-length, FALSE or whatever you feel is most appropriate.
-- Ken
In reply to Re: how to identify a null hash value
by kcott
in thread how to identify a null hash value
by smartyollie
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |