Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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

by afoken (Chancellor)
on May 20, 2010 at 04:43 UTC ( [id://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.

Alexander

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

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-04-24 09:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found