http://www.perlmonks.org?node_id=583319


in reply to Re^3: Benchmark of hash emptiness test
in thread Benchmark of hash emptiness test

Pardon my ignorance (I don't know much about the perl internals) but I was under the impression that there was something like boolean context. So shouldn't the hash in if (%hash) {} be able to tell that it was used in boolean context and thus react accordingly? This should then be an easy patch, just defining a different behaviour for %hash in boolean (in contrast to scalar) context.

-- Hofmator

Code written by Hofmator and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.