good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Count non-empty hash valuesby pboin (Deacon) |
on Oct 22, 2005 at 17:13 UTC ( [id://502229]=perlquestion: print w/replies, xml ) | Need Help?? |
pboin has asked for the wisdom of the Perl Monks concerning the following question: I'm trying to improve my perl-fu a bit, and I think this is a case where I could map or grep. However, it's not working the way I think it should, and I could use a nudge... Now, a FAQ is How do I find out if a hash is empty?. That's not exactly what I want to do. I have a hash, I know there are keys out there, but I want to get a quick count of how many of those keys have non-empty values. Here's a mini-case that I think should work (but doesn't):
I think that the matching operator is having its results stored in @rtn. Then, when I get use that return in scalar context, the result isn't quite what I was looking for. Now I have to figure out how many non-empties are in my array instead of my hash, which is pretty much where I started. Thank you Monasterians...
Back to
Seekers of Perl Wisdom
|
|