Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: Help Perl Program - I have compilation errors don't know where

by afoken (Abbot)
on May 20, 2010 at 04:43 UTC ( #840850=note: print w/replies, xml ) Need Help??

in reply to Help Perl Program - I have compilation errors don't know where

Another small note: Don't abuse the strings "false" and "true" as replacement for boolean values. It makes your code harder to maintain, and it is more work for perl. Worst of all, Perl consideres BOTH values as true. There are exactly three values that Perl treats as false: 0, '', and undef, and you really should use one of those, preferably the first or the second, instead of "false". All other values are treated as true, but except in rare cases, you should use 1.

So: replace "false" with 0 or '', replace "true" with 1. Replace $whatever eq "true" with $whatever, replace $whatever eq "false" with !$whatever.


Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Replies are listed 'Best First'.
Re^2: Help Perl Program - I have compilation errors don't know where
by cdarke (Prior) on May 20, 2010 at 08:48 UTC
    While I agree completely with the spirit of the reply, the pedant in me demands that I quote the following from perlsyn:

    The number 0, the strings '0' and '', the empty list (), and undef are all false in a boolean context.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://840850]
[Yary]: ah thanks for those links
[hippo]: Just bear in mind that all such ideas are subjective.
[choroba]: There might be a different standard at the shop you write the code for.
[choroba]: The order of package - (strict+warnings | warnings+strict) - modules makes sense, POD and strict-warnings order are not so important

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2018-01-23 17:07 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (250 votes). Check out past polls.