in reply to Re^2: Scope, package, and 'my' variables
in thread Scope, package, and 'my' variables
Each example must be run separately. You're getting the value of $x defined from the previous test. If you run the 2nd one by itself, however:
$ perl -le ' BEGIN { my $x = 1; } print defined $x ? "defined" : "undefined";' undefined
And with strict:
$ perl -Mstrict -le ' BEGIN { my $x = 1; } print $x;' Global symbol "$x" requires explicit package name at -e line 2. Execution of -e aborted due to compilation errors.
|
|---|