Hi! I am trying to compare 2 arrays and when there is match in the second array, wants to print the element, the one before and the one after the match.
when using only one matching element, it works, see below.
my @num = (1..20);
foreach $num(@num){
$count++;
if ($num == 2) {
print FILEW1 "$num[$count-2]\t$num\t$num[$count]\n";
}
}
but when i try to loop through all elements of the array1 to find matching elements in array2, it does not,
foreach $arr(@arr){
foreach $tmpvar(@tmpva){
$count++;
if ($arr eq $tmpvar){
print FILEW1 $tmpvar[$count-2]\t$tmpvar\t$tmpvar[$count]\n";
}
}
}
Thanks in advance