Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^3: Supressing warnings

by almut (Canon)
on Jul 22, 2010 at 21:39 UTC ( #850918=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Supressing warnings
in thread Supressing warnings

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.)


Comment on Re^3: Supressing warnings
Download Code
Re^4: Supressing warnings
by morgon (Deacon) on Jul 22, 2010 at 23:27 UTC
    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 "a.pl" you get your command-line flags from the shebang-line and when you run it as "perl <whatever flags> a.pl" 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 myscript.pl .

Re^4: Supressing warnings
by morgon (Deacon) on Jul 22, 2010 at 23:41 UTC
    #!/home/mh/perl512/bin/perl -w warn "Hubba\n"; # script a.pl, produces warning

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

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

    UPDATE:

    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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2015-07-05 05:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls