Here are two ways:
$a = 'a';
@b = qw(a b c);
#####
#(1)# Iterate till found
foreach(@b){
if($a eq $_){
print "Found it!\n";
}
}
#####
#(2)# Use a hash
foreach(@b){
$c{$_} = 1;
}
if($c{$a}){
print "\$a is in there.\n";
}else{
print "No it's not.\n";
}
-----Original Message-----
From: Alex Cheung Tin Ka [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 17, 2002 7:27 PM
To: [EMAIL PROTECTED]
Subject: question in list
Dear All,
I have a problem about the list value.
I have got a scalar say $a='a' and a list say @b = ('a', 'b','c');
how can I check whether $a is one of the value in @b. Is there any easy
way to do it and I got lost in perl.com's piles of documentation.
Thanks
Alex
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]