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

Re: Perl 7 - updates

Thread Previous | Thread Next
From:
David Mertens
Date:
July 4, 2020 02:22
Subject:
Re: Perl 7 - updates
Message ID:
CA+4ieYW0LhKn19LbfqMG55MXFjcsn1u41fYE6e6bB6FjtO7NcQ@mail.gmail.com
Perl does not idly ignore the first line if it is a shebang line. In fact,
it examines the shebang line for command line switches and enables them.

On Fri, Jul 3, 2020, 9:37 PM Darren Duncan <darren@darrenduncan.net> wrote:

> On 2020-07-03 5:35 p.m., Todd Rinaldo wrote:
> > 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.
>
> I'm quite sure that is wrong.
>
> The only real purpose of the shebang line is to help a shell know to run
> Perl
> and not say Python when you just say something like this:
>
>    ./myapp.pl
>
> Whereas, once Perl is actually running and given the file, that line has
> no
> purpose and is just a completely optional comment.
>
> And so, if you run a program like this instead:
>
>    perl myapp.pl
>
> Then it will just work even with no shebang line in the file.
>
> In fact I've heard it often argued that having a shebang line for the most
> part
> is an obsolete notion and it is best to NOT have it, especially as in the
> general case what it says is completely wrong.  What if your Perl lives
> somewhere else?  Or what if you're running Windows?
>
> Although a lot of that is addressed by using a different more adaptable
> shebang
> line like either of these:
>
>    #!perl
>    #!which perl
>    #!/usr/bin/which perl
>
> But still, at the very least, only the main program has any business
> containing
> a shebang line and any library files just called by other Perl files with
> "use"
> etc have no reason to contain them.
>
> -- Darren Duncan
>

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