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