Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Need help testing to see if a variable is one value or the other

by traveler (Parson)
on Jan 30, 2008 at 22:36 UTC ( [id://665234]=note: print w/replies, xml ) Need Help??


in reply to Need help testing to see if a variable is one value or the other

Or, if GrandFather's solution is too elegant and simple, you can use a module. (It is way overkill here, though!)
use strict; use Set::Scalar; my $s = Set::Scalar->new( qw/yes no/ ); my $var = "no"; if ( $s->has($var)){ print "found $var\n"; } else{ print "never heard of $var\n"; }
  • Comment on Re: Need help testing to see if a variable is one value or the other
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-19 17:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found