if( exists($hash->{akey}) && defined($m=$hash->{akey}) && ($m==1) ){ $y = $m; ... } # don't trust $m here