Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re^2: Supressing warnings

by morgon (Curate)
on Jul 22, 2010 at 21:22 UTC ( #850915=note: print w/replies, xml ) Need Help??

in reply to Re: Supressing warnings
in thread Supressing warnings

The #! line is always examined for switches as the line is being parsed.

Funny, I never knew that. It does not even need to contain a path to perl, all it needs is an occurance of the string "perl".

If e.g. starts with "#!end lines properly! -d", then "perl" starts the debugger.

I hope I find a way to turn this knowledge into a beer at the upcoming YAPC::Europe (even though I think this behavour does not really makes sense).

Replies are listed 'Best First'.
Re^3: Supressing warnings
by almut (Canon) on Jul 22, 2010 at 21:39 UTC
    I think this behavour does not really makes sense

    I'd say it makes a lot of sense :)

    (For example, at 5.8 times when there was no say, -l was one of my favorite options to put in the shebang line for short test scripts.)

      Yeah, ok there may be some uses like yours (which I would consider a hack), but in general (at least that would be the behaviour of least surprise) you (ok: I) would expect that when you run a script as "" you get your command-line flags from the shebang-line and when you run it as "perl <whatever flags>" your get it from - well - the command line.

      With this behaviour I cannot run a script with different flags without having to modify it if it contains a shebang lines with flags.

      Do Python and Ruby do this as well?

        With this behaviour I cannot run a script with different flags without having to modify it if it contains a shebang lines with flags.

        You could also argue the other way round, i.e. it provides for consistency independently of how exactly the interpreter is being invoked — in particular as there are some operating system that don't handle shebangs (one rather commonly used one is among them...).

        And some options might be an integral part of a script, or at least important to its proper functioning — like -n, -p, -l, -C (which didn't work on the shebang line until recently, btw), etc. — so I would rather want them to remain in effect when I call the script as perl .

      #!/home/mh/perl512/bin/perl -w warn "Hubba\n"; # script, produces warning

      When you run this as "perl -X" you still get the warning - even though -X should disable them.

      Is that because -w (from shebang) is "stronger" than -X (from command line)?


      The above is crap - sorry.

        I think the reason Morgon says it's crap is because -w has no effect on warn. If you change the test to actually produce a warning, then the -X on the command line is indeed "stronger" than the -w in the shebang, but that's because the -X is always stronger than the -w, even if they swap places, or are both together on the command line or both together in the shebang.

        - Boldra

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://850915]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2017-01-16 11:16 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (149 votes). Check out past polls.