From ee45726178d0bb0e557f384dfd288e1acca59a91 Mon Sep 17 00:00:00 2001 From: "Paul \"LeoNerd\" Evans" Date: Fri, 19 Jan 2024 15:33:17 +0000 Subject: [PATCH] perl -E should enable corresponding builtin version bundle --- pod/perlrun.pod | 4 ++-- t/run/switches.t | 7 ++++++- toke.c | 3 ++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/pod/perlrun.pod b/pod/perlrun.pod index 6ed5703811d2e..7bc264eee17c5 100644 --- a/pod/perlrun.pod +++ b/pod/perlrun.pod @@ -470,8 +470,8 @@ to use semicolons where you would in a normal program. X<-E> behaves just like L<-e|/-e commandline>, except that it implicitly -enables all optional features (in the main compilation unit). See -L. +enables all optional features and builtin functions (in the main +compilation unit). See L and L. =item B<-f> X<-f> X X diff --git a/t/run/switches.t b/t/run/switches.t index 50318fc32b9be..f72949f2ca6f8 100644 --- a/t/run/switches.t +++ b/t/run/switches.t @@ -695,7 +695,12 @@ $TODO = ''; # the -E tests work on VMS $r = runperl( switches => [ '-E', '"say q(Hello, world!)"'] ); -is( $r, "Hello, world!\n", "-E say" ); +is( $r, "Hello, world!\n", "-E enables 'say' feature" ); + +$r = runperl( + switches => [ '-E', '"say reftype []"'] +); +is( $r, "ARRAY\n", "-E enables 'reftype' builtin" ); $r = runperl( switches => [ '-nE', q("} END { say q/affe/") ], diff --git a/toke.c b/toke.c index 9e0e9df1c35ed..dd3bbdd0b6801 100644 --- a/toke.c +++ b/toke.c @@ -9240,7 +9240,8 @@ yyl_try(pTHX_ char *s) } if (PL_minus_E) sv_catpvs(PL_linestr, - "use feature ':" STRINGIFY(PERL_REVISION) "." STRINGIFY(PERL_VERSION) "';"); + "use feature ':" STRINGIFY(PERL_REVISION) "." STRINGIFY(PERL_VERSION) "'; " + "use builtin ':" STRINGIFY(PERL_REVISION) "." STRINGIFY(PERL_VERSION) "';"); if (PL_minus_n || PL_minus_p) { sv_catpvs(PL_linestr, "LINE: while (<>) {"/*}*/); if (PL_minus_l)