Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

if statements

by root (Scribe)
on Nov 05, 1999 at 03:58 UTC ( #946=perltutorial: print w/ replies, xml ) Need Help??

if statements test a control statement to see whether it is true or false. else and elsif clauses can also be tagged on the back.
#your basic if if($value==1){ print "value is equal to 1\n"; } #your basic if/else if($value==1){ print "value is equal to 1\n"; } else{ print "value is not equal to 1\n"; } #your basic if/elsif/else if($value==1){ print "value is equal to 1\n"; } elsif($value==2){ print "value is equal to 2\n"; } elsif($value==3){ print "value is equal to 3\n"; } else{ print "value is not equal to 1,2, or 3\n"; }
Unless statements offer you the opposite functionality. If the control statement evaluates to false then the statements inside the block are executed.

Comment on if statements
Download Code
Re: if statements
by NodeReaper (Curate) on Mar 16, 2001 at 23:48 UTC

    Reason: prolly a troll in light of all those other ones.

    For more information on this node visit: this

Re: if statements
by NodeReaper (Curate) on Apr 10, 2002 at 08:54 UTC

    Reason: (ariels) DELETE: Unformatted. Not Perl code. No correspondent to ask to fix (AM)

    For more information on this node visit: this

Re: if statements
by Mr. Muskrat (Abbot) on Jun 16, 2002 at 14:36 UTC
    Something else that should be mentioned... You can reverse if statements:

    ++$node if $votes > 0;
      Please supply an example of your reverse if statement syntax... PL
        That is a reversal of the "usual" if at the front of the statement.

Log In?
Username:
Password:

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

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

    For retirement, I am banking on:










    Results (92 votes), past polls