Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Perl: porters

[PATCH] Handle PL_minus_E before PL_minus_{n,p}.

 

 

Perl porters RSS feed   Index | Next | Previous | View Threaded


rafl at debian

May 10, 2008, 10:51 PM

Post #1 of 2 (88 views)
Permalink
[PATCH] Handle PL_minus_E before PL_minus_{n,p}.

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


rgarciasuarez at gmail

May 11, 2008, 8:10 AM

Post #2 of 2 (80 views)
Permalink
Re: [PATCH] Handle PL_minus_E before PL_minus_{n,p}. [In reply to]

2008/5/11 Florian Ragwitz <rafl[at]debian.org>:
> This allows the features enabled by -E to be available outside of the
> blocks added by -{n,p} like in

Thanks, applied as #33822 to bleadperl.

Perl porters RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.