in reply to Finding the index of a specific element in an array.

There are many ways to write this code. One of those ways is with grep. You could make a foreach loop to do the same thing.
#!/usr/bin/perl -w use strict; my @array = (2,4,7,5,8); # grep would return indicies of all 7's # here, just the first one is all we keep track of my ($first_seven) = grep{$array[$_] == 7}(0..@array-1); print $first_seven; # prints 2