for (my $i = 0; $i < @foo; ++$i) { if ($foo[$i] eq $match_element) { return $i; } }