use strict; use warnings; my $foo = undef; if ( !defined $foo ) { print "\$foo is undef\n"; } else { print "\$foo is defined\n"; }