![]() |
|
Perl-Sensitive Sunglasses | |
PerlMonks |
Re^2: Defined vs. undefinedby misterb101 (Sexton) |
on Feb 10, 2006 at 15:57 UTC ( #529393=note: print w/replies, xml ) | Need Help?? |
xdg, you're right, but then the question is why one would use a variable that is potentially undefined?? for this, testing whether the hash has values is better like in muntfish's solution. But if you go that route, why don't you directly test if (scalar(%hash)!=0) { ....?? using a hash in scalar context gives 0 for a empty hash and the number of used entries for a nonempty hash. my %hash = (1=>2,3=>4);print "scalarval=".scalar(%hash); => 2/8 Cheers, Rob
In Section
Seekers of Perl Wisdom
|
|