Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: if/else syntax

by suaveant (Parson)
on Jun 26, 2009 at 15:07 UTC ( [id://775084]=note: print w/replies, xml ) Need Help??


in reply to if/else syntax

If you want an "else" with an if, you need the brackets, "if" after the statement is a modifier, not a control block... if you just need the else, use unless
print "OK\n" unless $a == 1;

Update: I suppose you could do

print "OK\n" if $a == 1; print "Not OK\n" unless $a == 1;
But don't. ;)

                - Ant
                - Some of my best work - (1 2 3)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-16 23:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found