foreach my $i (0 .. @txttoken) { my $txtline = $txttoken[$i]; foreach my $j (0 .. @$txtline) { if ($txtline->[$j] eq "temeli" and $pstoken[$i][$j] eq "n") { do_something(); } } }