In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/01851bb732f478a582c55dbed16459f8a0da7ec5?hp=5f244db984d907853a5bd0b598472da074dc2c8d>

- Log -----------------------------------------------------------------
commit 01851bb732f478a582c55dbed16459f8a0da7ec5
Merge: 5f244db... 5cc917d...
Author: Rafael Garcia-Suarez <[email protected]>
Date:   Tue Jul 7 22:32:39 2009 +0200

    Merge branch 'strict-by-default' into blead

commit 5cc917d61a1b0b6683ece694d00cdb1abdf9c0d9
Author: Rafael Garcia-Suarez <[email protected]>
Date:   Tue Jul 7 11:04:13 2009 +0200

    Fast enabling of strictures when version 5.11.0 is required
    
    We don't load strict.pm, we just manipulate the hint bits.
    Plus more tests.

M       pod/perlfunc.pod
M       pp_ctl.c
M       t/comp/use.t

commit 53eb19dd57d98e5a28ec6e1a56a1a40ce469145f
Author: Steffen Mueller <[email protected]>
Date:   Tue Jul 7 10:27:50 2009 +0200

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

M       pod/perlfunc.pod
M       pp_ctl.c
M       t/comp/use.t
M       t/run/switches.t
-----------------------------------------------------------------------

Summary of changes:
 pod/perlfunc.pod |    3 +++
 pp_ctl.c         |    5 +++++
 t/comp/use.t     |   18 +++++++++++++++++-
 t/run/switches.t |    7 ++++++-
 4 files changed, 31 insertions(+), 2 deletions(-)
 mode change 100644 => 100755 t/comp/use.t

diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index 884644e..2035795 100644
--- a/pod/perlfunc.pod
+++ b/pod/perlfunc.pod
@@ -6947,6 +6947,9 @@ 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> (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
diff --git a/pp_ctl.c b/pp_ctl.c
index 59ac8c1..eab9624 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -3255,6 +3255,11 @@ 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) {
+           PL_hints |= (HINT_STRICT_REFS | HINT_STRICT_SUBS | 
HINT_STRICT_VARS);
+       }
 
        RETPUSHYES;
     }
diff --git a/t/comp/use.t b/t/comp/use.t
old mode 100644
new mode 100755
index d3a3568..8546123
--- 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..68\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,19 @@ 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/);
+# 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
 
 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();

--
Perl5 Master Repository

Reply via email to