Given an array @A
we want to check if the element $B
is in it. One way is to say this:
Foreach $element (@A){
if($element eq $B){
print "$B is in array A";
}
}
However when it gets to Perl, I am thinking always about the most elegant way. And this is what I am thinking: Is there a way to find out if array A contains B if we convert A to a variable string and use
index(@A,$B)=>0
Is that possible?