How can variables be set to NULL under the strict pragma?
There's no NULL in Perl. However, variables can be undef
ined, which means that they have no value set.
Here're some examples of how you can get an undefined variable in Perl:
my $var; # variables are undefined by default
undef $var; # undef() undefines the value of a variable
$var = undef; # same, using an alternative syntax
To check for definedness of a variable, use defined()
, i.e.
print "\$var is undefined\n" unless defined $var;