Also, if the specified perl version is greater than or equal to 5.9.5,
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;>.
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
Perl_load_module(aTHX_ 0, newSVpvs("feature"), NULL, importsv, NULL);
LEAVE;
}
+ /* 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;
+ }
+
RETPUSHYES;
}
$INC{"feature.pm"} = 1; # so we don't attempt to load feature.pm
}
-print "1..63\n";
+print "1..65\n";
# Can't require test.pl, as we're testing the use/require mechanism here.
eval "use 5.10;";
like ($@, qr/Perl v5\.100\.0 required \(did you mean v5\.10\.0\?\)--this is only \Q$^V\E, stopped/);
+eval "use 5.11;";
+like ($@, qr/Perl v5\.110\.0 required \(did you mean v5\.11\.0\?\)--this is only \Q$^V\E, stopped/);
+
eval sprintf "use %.6f;", $];
is ($@, '');
eval sprintf "use %.6f;", $] + 0.00001;
like ($@, qr/Perl v5.\d+.\d+ required--this is only \Q$^V\E, stopped/);
+# 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/);
+
{ use lib } # check that subparse saves pending tokens
local $lib::VERSION = 1.0;
BEGIN { require "./test.pl"; }
-plan(tests => 70);
+plan(tests => 71);
use Config;
);
is( $r, "affe\n", '-E works outside of the block created by -n' );
+$r = runperl(
+ switches => [ '-E', q("*{'bar'} = sub{}; print 'Hello, world!',qq|\n|;")]
+);
+is( $r, "Hello, world!\n", "-E does not enable strictures" );
+
# RT #30660
$filename = tempfile();