I have the following (idealised from a bug) short script in Perl:
my %metadata = undef;
if (defined %metadata)
{
print "defined";
}
For some reason the output of the program is always "defined". So setting the hash to be "undefined" somehow makes it defined. Is it defined as being "undefined"?
EDIT:
This is an idealised case, in an attempt to replicate the problem. What I'm actually doing is more like:
my %metadata = my_sub_function();
if (defined %metadata)
{
print "defined";
}
Where the output of my_sub_function may be undef, () or a populated hash, and I only want to print "defined" in the last of these cases.
EDIT 2:
Incidentally I have found that
if (scalar(keys %metadata)
behaves correctly for (), but still not for undef.