Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: Range Operator in If Statement

by ambrus (Abbot)
on Jan 05, 2012 at 11:43 UTC ( #946373=note: print w/replies, xml ) Need Help??


in reply to Re^2: Range Operator in If Statement
in thread Range Operator in If Statement

If you have multiple consecutive intervals, it's better to use an elsif cascade, such as

if ($ref <= 8) { say "ref is at most 8."; } elsif ($ref <= 16) { say "ref is above 8 but at most 16." } elsif ($ref <= 24) { say "ref is above 16 but at most 24." } elsif ($ref <= 32) { say "ref is above 24 but at most 32." } else { sat "ref is above 32." }
The elsif part means that if the previous condition was found true, the next one is not tested for, so eg. if $ref = 5 then the first branch is executed, the rest of the tests and branches are skipped.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://946373]
help
Chatterbox?
[Discipulus]: thanks choroba.. todo list need a pager..

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (11)
As of 2017-11-24 12:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (348 votes). Check out past polls.

    Notices?