From: Steffen Mueller <smueller@cpan.org>
Date: Tue, 7 Jul 2009 08:27:50 +0000 (+0200)
Subject: use strict by default if "use 5.011" is in effect!
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=53eb19dd57d98e5a28ec6e1a56a1a40ce469145f;p=p5sagit%2Fp5-mst-13.2.git

use strict by default if "use 5.011" is in effect!
---

diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index 884644e..878d206 100644
--- a/pod/perlfunc.pod
+++ b/pod/perlfunc.pod
@@ -6947,6 +6947,8 @@ C<use>ing library modules that won't work with older versions of Perl.
 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
diff --git a/pp_ctl.c b/pp_ctl.c
index 59ac8c1..75d98dd 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -3255,6 +3255,14 @@ PP(pp_require)
 	    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;
     }
diff --git a/t/comp/use.t b/t/comp/use.t
old mode 100644
new mode 100755
index d3a3568..30e41bb
--- a/t/comp/use.t
+++ b/t/comp/use.t
@@ -6,7 +6,7 @@ BEGIN {
     $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.
 
@@ -89,6 +89,9 @@ like ($@, qr/Perl v5\.900\.0 required \(did you mean v5\.9\.0\?\)--this is only
 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 ($@, '');
 
@@ -102,6 +105,10 @@ like ($@, qr/Perl v6.\d+.\d+ required--this is only \Q$^V\E, stopped/);
 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;
diff --git a/t/run/switches.t b/t/run/switches.t
index a9e23ea..839a860 100644
--- a/t/run/switches.t
+++ b/t/run/switches.t
@@ -11,7 +11,7 @@ BEGIN {
 
 BEGIN { require "./test.pl"; }
 
-plan(tests => 70);
+plan(tests => 71);
 
 use Config;
 
@@ -352,6 +352,11 @@ $r = runperl(
 );
 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();