Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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

by lodin (Hermit)
on Feb 01, 2008 at 11:48 UTC ( #665546=note: print w/replies, xml ) Need Help??


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

This is pretty much the same as jozxyqk's reply, except it doesn't pull in given/when. The only modification to your code is to replace eq ("yes" or "no") with ~~ [ "yes", "no" ].

#!/usr/bin/perl -w use strict; my $var = "yes"; if ($var ~~ [ "yes", "no" ]) { print "You choose $var\n"; }else{ print "you chose something other then yes or no\n" }

lodin

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2022-01-28 20:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (73 votes). Check out past polls.

    Notices?