Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: A newbie's first try at conditionals

by Maclir (Curate)
on Aug 17, 2002 at 03:30 UTC ( #190815=note: print w/replies, xml ) Need Help??


in reply to A newbie's first try at conditionals

As others have mentioned, your parentheses are unbalanced. I have a similar problem in complex conditional statements, and I have found a trick that helps me - at least when I am developing the code.

Instead of having the conditional all on the one line, like if (($Age < 13) && ($Age > 0)) I try to space things out, like:

if (($Age < 13) && ($Age > 0) ) { some block of statements; } elsif (($Age < 18) && ($Age > 12)) ) { another block of statements; } else { a final block; }
This makes a visual scan of the whole if - elsif - else block easier. Once it all works, you cansquash the lines up if you wish.

Once you start to get into complex data structures then this can solve a lot of stilly typographical erors.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://190815]
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: (2)
As of 2023-03-25 17:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (63 votes). Check out past polls.

    Notices?