http://qs1969.pair.com?node_id=263402


in reply to Counting keys with defined or undefined elements in a hash

This does iterate over the whole hash, but it should be pretty nippy since the iteration is done internally
my %hash = ( foo => 1, bar => 1, baz => 1, one => undef, two => undef, three => undef, ); print "defined - ", scalar(grep defined, values %hash), $/; print "not defined - ", scalar(grep !defined, values %hash), $/; __output__ defined - 3 not defined - 3
See. grep and values for more info.
HTH

_________
broquaint