Hey! A "C-style" for loop. I guess it contains an off-by-one error.for (my $i = 0; $i < @array; $i++) { if ($array[$i] == 7) { say "The index is $i"; last; } }
In reply to Re: Finding the index of a specific element in an array.
by JavaFan
in thread Finding the index of a specific element in an array.
by Thakur
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |