Simon Oliver wrote:
EXTERN Chakirov Timour (TZ CIS; DS/ESQ3) wrote:

Hello,

I know it's a dummy question, however I could not find a quick answer in
perl documentation.
So my question: is any form of "logical-IN" operator in perl? I.e. I have a
scalar $var and a list @colors = ['red', 'yellow', 'green']. All I want is
to check


if ($var in @color) {
    traffic_lite($var)
}

How could I realise this code in perl?

Or use a hash:

my %colors = (red=>1, yellow=>1, green=>1);
my $var = 'yellow';

if (exists $colors{$var}) {
   print($var);
}

--
  Simon Oliver

_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to