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

Re^2: long if statements... What's the best way?

by lodin (Hermit)
on Apr 03, 2008 at 12:32 UTC ( [id://678149]=note: print w/replies, xml ) Need Help??


in reply to Re: long if statements... What's the best way?
in thread long if statements... What's the best way?

Be aware of false strings that match.

use List::Util 'first'; my $var = '0'; if (first { $_ eq $var } $var) { print "Found.\n"; } else { print "Not found.\n"; } __END__ Not found.
You could solve this by using defined in this particular case, but it's not a general solution. As Herkum says, any from List::MoreUtils is a better alternative in the general case.

lodin

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-24 22:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found