I am using use strict; in perl and with that I use the following statement.
unless(defined($x)){
print "Not defined";
}
Where $x is not declared anywhere. So I expect it to print “Not defined” but it returns an error
Global symbol "$x" requires explicit package name at *********** in line 15.
The
strictpragma has three parts: strict references, strict variables, and strict subs. The one you’re running into isBecause it generates compile-time errors, your non-
BEGINcode won’t even have a chance to run. You can temporarily allow non-strict variables inside a block as inbut note that Perl’s
definedoperator tells you whether a value is defined, not whether a variable has been declared.Tell us more about your application, and we can give you better advice about how to handle it.