Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Range Operator in If Statement

by TJPride (Pilgrim)
on Jan 05, 2012 at 05:29 UTC ( #946325=note: print w/ replies, xml ) Need Help??


in reply to Range Operator in If Statement

If the ranges you're matching on are consecutive, you could do something like this:

use strict; use warnings; for (-4, 1, 7, 12, 89, 54, 13, 104) { if ($_ < 1 || $_ > 64) { print "$_ outside.\n" } elsif ($_ <= 8) { print "$_ 1-8\n"; } elsif ($_ <= 16) { print "$_ 9-16\n"; } elsif ($_ <= 32) { print "$_ 17-32\n"; } elsif ($_ <= 64) { print "$_ 33-64\n"; } }


Comment on Re: Range Operator in If Statement
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2014-08-01 03:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (256 votes), past polls