develooper Front page | perl.perl5.porters | Postings from July 2020

Re: Perl 7 - updates

Thread Previous | Thread Next
Todd Rinaldo
July 4, 2020 00:36
Re: Perl 7 - updates
Message ID:

> On Jul 3, 2020, at 7:28 PM, Kent Fredric <> wrote:
> On Sat, 4 Jul 2020 at 12:10, Todd Rinaldo <> wrote:
>> I'm working on a module right now that will walk a file tree and auto-inject 'use v5;' at the top of any Perl code (as the first line of the file after any #!) that does not have use vX. It then also auto-updates the XS code with its faulty version checks. I think this will solve 99% of CPAN and the 1% outlier (I don't know of any outliers at the moment) can be fixed by hand if it needs it.
> Something to consider:
> I recall seeing some perl scripts which had a nice little blob of code
> at the top, which did nothing on perl, but due to *also* being valid
> bash, prevented bash getting carried away trying to execute the rest
> of the code as bash script.
> If there's a way to do that nicely, that'd be cool. ( Though I
> speculate this will very much fall into a hard basket, as `use vX`
> probably isn't valid bash )

This used to live at the top of some cPanel perl code until we found a better solution. It allowed the code to fall back to system perl in the event cPanel Perl was broken in some way.

eval 'if [ -x /usr/local/cpanel/3rdparty/bin/perl ]; then exec /usr/local/cpanel/3rdparty/bin/perl -x -- $0 ${1+"$@"}; else exec /usr/bin/perl -x $0 ${1+"$@"}; fi;'
  if 0;


As far as I understand, the Perl parser doesn't start parsing the code until it sees #!/usr/bin/perl in which case you just put use v7 after that line.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About