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

Re: Perl 7 - updates

Thread Previous | Thread Next
From:
Tomasz Konojacki
Date:
July 4, 2020 09:58
Subject:
Re: Perl 7 - updates
Message ID:
20200704115829.1374.5C4F47F8@xenu.pl
On Sat, 4 Jul 2020 01:21:36 -0500
Todd Rinaldo <toddr@cpanel.net> wrote:

> > A much less obscure example of that are batch scripts generated by
> > pl2bat, which is used for *all* scripts installed from CPAN on windows.
> > For example, this is how cpan.bat (a wrapper of 'cpan' from CPAN.pm)
> > looks like:
> > 
> > @rem = '--*-Perl-*--
> > @echo off
> > if "%OS%" == "Windows_NT" goto WinNT
> > IF EXIST "%~dp0perl.exe" (
> > "%~dp0perl.exe" -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
> > ) ELSE IF EXIST "%~dp0..\..\bin\perl.exe" (
> > "%~dp0..\..\bin\perl.exe" -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
> > ) ELSE (
> > perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
> > )
> > 
> > goto endofperl
> > :WinNT
> > IF EXIST "%~dp0perl.exe" (
> > "%~dp0perl.exe" -x -S %0 %*
> > ) ELSE IF EXIST "%~dp0..\..\bin\perl.exe" (
> > "%~dp0..\..\bin\perl.exe" -x -S %0 %*
> > ) ELSE (
> > perl -x -S %0 %*
> > )
> > 
> > if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl
> > if %errorlevel% == 9009 echo You do not have Perl in your PATH.
> > if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul
> > goto endofperl
> > @rem ';
> > #!/usr/local/bin/perl
> > #line 29
> > 
> > BEGIN { pop @INC if $INC[-1] eq '.' }
> > use strict;
> > use vars qw($VERSION);
> > 
> > use App::Cpan;
> > 
> > # (...) more perl code
> > 
> > :endofperl
> > 
> 
> Cool. The looks like -x will save the day here too and we can put use vX after #!/usr/local/bin/perl. Do you agree?
> 
> Todd

I was worried about the case when the script calls something like system($^X,
$0) but, on a second thought, use VERSION is lexical, so it doesn't apply
to @rem='...' at the beginning of the quine.

It would break if strict was enabled by default, though.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About