Lance Prais wrote at Fri, 27 Sep 2002 01:55:31 +0200:
> If a=b or a=c or a=d do this How would I do that?
>
> I thought I could do it like this but it did not work.
>
> 1.
> If ($a=b) || ($a=c) || ($a=d)
> {
> DO this
> }
>
> 2.
> If ($a=b) || if ($a=c) || if ($a=d)
> {
> DO this
> }
If there are some things to compare with for equality,
it's sometime also a good idea to use a hash for a direct lookup:
my %valid_value = map {$_ => 1} (qw/b c d));
if ($valid_value{$a}) {
...
}
If time doesn't play any role, but nice code does,
there's also the
use Quantum::Superpositions;
if ($a == any(qw/b c d)) {
...
}
way.
Greetings,
Janek
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]