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

Re: Perl 7 - updates

Thread Previous | Thread Next
Darren Duncan
July 4, 2020 01:37
Re: Perl 7 - updates
Message ID:
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:


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:


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:

   #!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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About