We don't load strict.pm, we just manipulate the hint bits.
Plus more tests.
C<use VERSION> will also load the C<feature> pragma and enable all
features available in the requested version. See L<feature>.
Similarly, if the specified perl version is greater than or equal to
-5.11.0, strictures are enabled lexically as with C<use strict;>.
+5.11.0, strictures are enabled lexically as with C<use strict> (except
+that the F<strict.pm> file is not actually loaded).
The C<BEGIN> forces the C<require> and C<import> to happen at compile time. The
C<require> makes sure the module is loaded into memory if it hasn't been
/* If a version >= 5.11.0 is requested, strictures are on by default! */
if (PL_compcv &&
vcmp(sv, sv_2mortal(upg_version(newSVnv(5.011000), FALSE))) >= 0) {
- ENTER;
- Perl_load_module(aTHX_ 0, newSVpvs("strict"), NULL, NULL, NULL);
- LEAVE;
+ PL_hints |= (HINT_STRICT_REFS | HINT_STRICT_SUBS | HINT_STRICT_VARS);
}
-
RETPUSHYES;
}
name = SvPV_const(sv, len);
$INC{"feature.pm"} = 1; # so we don't attempt to load feature.pm
}
-print "1..65\n";
+print "1..68\n";
# Can't require test.pl, as we're testing the use/require mechanism here.
# check that "use 5.11.0" (and higher) loads strictures
eval 'use 5.11.0; ${"foo"} = "bar";';
like ($@, qr/Can't use string \("foo"\) as a SCALAR ref while "strict refs" in use/);
+# but that they can be disabled
+eval 'use 5.11.0; no strict "refs"; ${"foo"} = "bar";';
+is ($@, "");
+# and they are properly scoped
+eval '{use 5.11.0;} ${"foo"} = "bar";';
+is ($@, "");
+# and this doesn't happen with require
+eval 'require 5.11.0; ${"foo"} = "bar";';
+is ($@, "");
{ use lib } # check that subparse saves pending tokens