Front page | perl.perl5.porters |
Postings from May 2008
[PATCH] Handle PL_minus_E before PL_minus_{n,p}.
Thread Next
From:
Florian Ragwitz
Date:
May 11, 2008 04:59
Subject:
[PATCH] Handle PL_minus_E before PL_minus_{n,p}.
Message ID:
1210485078-19640-1-git-send-email-rafl@debian.org
This allows the features enabled by -E to be available outside of the
blocks added by -{n,p} like in
perl -nE'... } END { say "affe" }'
Also add a testcase.
---
t/run/switches.t | 8 +++++++-
toke.c | 6 +++---
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/t/run/switches.t b/t/run/switches.t
index b3fd934..e5ac5d1 100644
--- a/t/run/switches.t
+++ b/t/run/switches.t
@@ -11,7 +11,7 @@ BEGIN {
BEGIN { require "./test.pl"; }
-plan(tests => 68);
+plan(tests => 69);
use Config;
@@ -346,3 +346,9 @@ $r = runperl(
switches => [ '-E', '"given(undef) {when(undef) { say q(Hello, world!)"}}']
);
is( $r, "Hello, world!\n", "-E given" );
+
+$r = runperl(
+ switches => [ '-nE', q('} END { say q/affe/') ],
+ stdin => 'zomtek',
+);
+is( $r, "affe\n", '-E works outside of the block created by -n' );
diff --git a/toke.c b/toke.c
index 431938f..abdc54d 100644
--- a/toke.c
+++ b/toke.c
@@ -3688,6 +3688,9 @@ Perl_yylex(pTHX)
sv_free((SV*)PL_preambleav);
PL_preambleav = NULL;
}
+ if (PL_minus_E)
+ sv_catpvs(PL_linestr,
+ "use feature ':5." STRINGIFY(PERL_VERSION) "';");
if (PL_minus_n || PL_minus_p) {
sv_catpvs(PL_linestr, "LINE: while (<>) {");
if (PL_minus_l)
@@ -3719,9 +3722,6 @@ Perl_yylex(pTHX)
sv_catpvs(PL_linestr,"our @F=split(' ');");
}
}
- if (PL_minus_E)
- sv_catpvs(PL_linestr,
- "use feature ':5." STRINGIFY(PERL_VERSION) "';");
sv_catpvs(PL_linestr, "\n");
PL_oldoldbufptr = PL_oldbufptr = s = PL_linestart = SvPVX(PL_linestr);
PL_bufend = SvPVX(PL_linestr) + SvCUR(PL_linestr);
--
1.5.5.1
Thread Next
-
[PATCH] Handle PL_minus_E before PL_minus_{n,p}.
by Florian Ragwitz