Ryan Perry wrote:
>
> my %hash=(test=>{});
> print "true\n" if $hash{test};
> # prints true
>
> How can I tell if it's empty?
The hash you have created hash a single element with a key of 'test' and a value
of a reference to an empty hash. The only values in Perl that are false are
zero, the empty string, and undef. A hash reference is none of those and
therefore is true.
If you want to check whether that reference refers to a non-empty hash then you
should write
print "not empty" if keys %{$hash{test}};
HTH,
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/