Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^4: Modifying Arrays passed by reference to subroutine

by akho (Hermit)
on Jun 09, 2009 at 10:59 UTC ( #769845=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Modifying Arrays passed by reference to subroutine
in thread Modifying Arrays passed by reference to subroutine

My point was that sometimes undef may not lead to a warning, but your sub won't do what you expect it to. Lack of proper sub signatures is sometimes annoying.

perllexwarn also talks about code in modules; -w enables warnings anywhere, so other people's code (i.e. those people who knew what they were doing and turned off warnings for relevant parts of their code) will throw warnings at you. It may be a lot of warnings.

"Throwing a warning" is exactly equivalent to "returning useless stuff silently" in most scenarios; warnings are written to stderr, which is not available for a lot of programs. And even if it is available — most end users just ignore it. If your code is potentially destructive (and what code isn't) you should die in unexpected situations, not issue a warning.

Also: use warnings FATAL => 'all' is much more aggressive than -w.


Comment on Re^4: Modifying Arrays passed by reference to subroutine
Select or Download Code
Re^5: Modifying Arrays passed by reference to subroutine
by Marshall (Prior) on Jun 09, 2009 at 11:21 UTC
    I think we are pretty close to saying the same thing. You are correct that "undef" may not lead to a warning. Also correct that -w on the shebang line may cause other warnings..

    I have found that the simple: use warnings or -w is about the right idea and that FATAL would be wrong...This is ok for testing, but once an application is "out in the wild", I don't think so.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2014-10-21 05:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (96 votes), past polls