Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: IF condition with a range

by mr_ron (Chaplain)
on Jul 17, 2018 at 17:35 UTC ( #1218673=note: print w/replies, xml ) Need Help??


in reply to IF condition with a range

Another approach if you want exact integer match. Not that much shorter but flexible for bigger range or more matches. See also Syntax::Keyword::Junction for more terse.

use List::Util 'any'; if (any {$x == $_} $y, $y +1, $y -1)
Ron

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2022-12-07 10:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?