#!/web/soft/bin/perl %hash = ( 1 => 5, 2 => 10, 3 => 15, 4 => 20 ); if( defined( $hash{4} ) ) { print "defined 1\n"; # prints } undef( $hash{4} ); if( defined( $hash{4} ) ) { print "defined 2\n"; # does not print }