foreach my $x (0..$#{$arr1}) { if($arr1->[$x] eq $1){$found++} } #### foreach my $x (@$arr1) { if ($x eq $1) {$found++} }