Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: Issue with #!usr/bin/perl

by tobyink (Canon)
on Mar 13, 2013 at 07:56 UTC ( [id://1023137]=note: print w/replies, xml ) Need Help??


in reply to Re: Issue with #!usr/bin/perl
in thread Issue with #!usr/bin/perl

Actually on Windows, the shebang line is not ignored. The Operating System ignores it, but Perl pays attention. Compare:

#!/usr/bin/perl print undef;

with:

#!/usr/bin/perl -w print undef;

The former issues no warning; the latter warns about using an uninitialized value.

This is because in Perl, the shebang line performs two roles. It's used by Unix-like operating systems as a "dispatch mechanism" - to decide which program should interpret the script. And on all operating systems Perl parses it looking for command-line options. It doesn't honour all command line options found there (e.g. -M) but does some (like -w and -t).

package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

Replies are listed 'Best First'.
Re^3: Issue with #!usr/bin/perl
by DrHyde (Prior) on Mar 14, 2013 at 11:25 UTC
    There's also this useful trick for writing perl scripts that will run using whatever is the first perl in the $PATH:
    #!/bin/sh exec perl -x $0 #!perl # your perl code goes here

    "But why not use #!/usr/bin/env perl?", I hear you cry.

    Because env isn't always in /usr/bin - it's in /bin on some obscure platforms - and there can be "issues" with passing arguments to the executable via env.

Re^3: Issue with #!usr/bin/perl
by nagalenoj (Friar) on Mar 13, 2013 at 09:49 UTC
    Thanks for the clarification. As I haven't used windows machine for perl scripting, never encounter such and I didn't know this before.

    Thanks.

Re^3: Issue with #!usr/bin/perl
by Anonymous Monk on Feb 02, 2018 at 14:54 UTC
    what's the difference between shebang -w vs. use strict; use warnings; ? Thinking of putting a shebang at the top of all my scripts that say #!/perl/shebang - be a win32 japh you know this is pointless, even with the -w.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1023137]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2024-04-23 15:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found