Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: "Can't happen" bugs

by sfink (Deacon)
on Jan 17, 2007 at 06:04 UTC ( #595031=note: print w/ replies, xml ) Need Help??


in reply to "Can't happen" bugs

I ran into this one not long ago:

if ($x = 0) { return "zero"; } elsif ($x < 0) { return "negative"; } elsif ($x > 0) { return "positive"; } # Cannot reach here


Comment on Re: "Can't happen" bugs
Download Code
Re^2: "Can't happen" bugs
by jrockway (Acolyte) on Jan 18, 2007 at 23:47 UTC
    Beautiful! That's why you should always put the constant on the left:

    if(0 = $x) # Can't modify constant item in scalar assignment.

      Or use warnings:

      use warnings; my $x; if ($x = 0) { 1 } __END__ Found = in conditional, should be == at - line 4.

      lodin

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (11)
As of 2014-10-01 20:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (38 votes), past polls