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

Re^4: Two simple code style advice questions

by BrowserUk (Pope)
on Jan 16, 2013 at 15:33 UTC ( #1013590=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Two simple code style advice questions
in thread Two simple code style advice questions

It would seem to me that most Unix commands return 0 when things are "OK." So.. if you want to accuse me of showing my C programming roots, I plead guily.

I understand the derivation, but still, the bland token OK has always suggested TRUE to me, and always will.

Hence my suggested alternative of use constant NOERROR => 0; which seems less likely to cause confusion.

That said, I wouldn't define a constant for 0 at all. It simply isn't necessary to compare against zero in Perl. The clearest idiom is simply:

my $errstr = $case ? $msg[ $case ] : '';

But I'd still prefer setting $msg[ 0 ] == ''; and simply:

my $errstr = $msg[ $case ];

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.


Comment on Re^4: Two simple code style advice questions
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (16)
As of 2015-07-01 17:12 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 (12 votes), past polls