Use if exists $hash->{1} instead.
Nope, that will still cause $hash to become a hashref and print 1 if $hash; will print 1. exists takes a hash element, and you can't have a hash element without a hash! :)
In reply to Re^2: Why does testing a key create a hash?
by friedo
in thread Why does testing a key create a hash?
by johnnywang
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |