my $hash = undef; print "shouldn't print\n" if $hash; # still prints nothing if( ref( $hash ) =~ /HASH/ and exists( $hash->{1} ) ) { print "Autovivified\n"; # Won't print; } print "Still shouldn't print.\n";