Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: anonymous code blocks

by Codon (Friar)
on Sep 15, 2005 at 16:40 UTC ( #492322=note: print w/ replies, xml ) Need Help??


in reply to anonymous code blocks

Let me make one suggestion that may seem obvious to someone that has not been looking at this code before (You know that phenomenon where you look at the same block of code for hours trying to find the bug and then finally go ask someone to help you out and they point out the obvious error before you finish explaining the problem?). If you have an if ( ! some_test() ), it is generally more readable to say unless ( some_test() ). So using this logic

if ( ! $NONFATALERROR == 0 ) { ... }
becomes
unless ( $NONFATALERROR == 0 ) { ... }
which is really
unless ( ! $NONFATALERROR ) { ...
because any non-zero value (undef evaluates to 0 in this context) is TRUE. Using the same aurgument against unless ( ! some_test() ) as we did against if ( ! some_test() ), we then get
if ( $NONFATALERROR ) { ... }
It's nitpicking, to be sure, but minor changes can have major benefit for anyone that has to maintain the code later, even the original author.

Ivan Heffner
Sr. Software Engineer, DAS Lead
WhitePages.com, Inc.


Comment on Re: anonymous code blocks
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2014-11-28 04:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (193 votes), past polls