There are several ways to do this. One of the easiest is grep:
if (grep {$_ eq $e} @a) { # $e is in @a }
However, if this is done many times and/or if @a gets to be too large, a hash lookup can be useful:
my %lookup = map { $_ => 1 } @a; # only do this once if you can if (exists $lookup{$e}) { # $e is in @a }
Cheers,
Ovid
New address of my CGI Course.
In reply to Re: boolean IN(); function in perl like
by Ovid
in thread boolean IN(); function in perl like
by Frank John
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |