in reply to Re: Comparing against multiple values
in thread Comparing against multiple values
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.
|
---|
In Section
Seekers of Perl Wisdom