Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Comparing against multiple values

by traveler (Parson)
on Mar 18, 2002 at 22:04 UTC ( #152594=note: print w/replies, xml ) Need Help??


in reply to Comparing against multiple values

You could also use Meta::Ds::Hash. Something like this (untested):
use Meta::Ds::Hash; my($hash)=Meta::Ds::Hash->new(); $hash->insert($bar); $hash->insert($baz); $hash->insert($boo); # later if($hash->has($foo)) { print "Found it\n"; }
It would be interesting to compare these various solutions for large and small numbers of comparison sets.

HTH, --traveler

Replies are listed 'Best First'.
Re^2: Comparing against multiple values
by Anonymous Monk on Feb 09, 2018 at 16:03 UTC
    i don't know how to reply to the whole thread so i have used the last answer, sorry for that. if ($foo=~/$bar|$baz|$boo/){ is not strictly equivalent to if (($foo eq $bar) || ($foo eq $baz) || ($foo eq $boo)){ as =~ will be true for $foo=abc and $boo=ab but "abc" will not be eq to "ab" if you want them to be strictly equivalent then it will be something like : if ($foo=~/^$bar$|^$baz$|^$boo$/){ i have tested with string values but not with $var so maybe there is some \ to use at the good places for this to work regards.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://152594]
help
Chatterbox?
[usemodperl]: perl is not broken, perl is being broken by the web being broken by https, for the love of banking apps on free wifi at coffee shops or something...
[Veltro]: Wondering, would it be so hard to write a small application that you can access using http which forwards the request over web ussing ssl?
[Veltro]: are there not even tools for that?
[usemodperl]: the breakage is so fresh i guess not, so it's up to us! :-)
[usemodperl]: someone has yet to make that future famous free http to https proxy written in perl and supported by ads, paypal, patreon, etc to make millions of dollars a minute!
[Veltro]: Why would this be fresh, I recon this is stuff that happens all the time (not Perl per se)
[Corion]: usemodperl: I'm sure you could even code that on the command line.

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2018-06-24 17:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (126 votes). Check out past polls.

    Notices?