my $index = get_index(\@array, $element); sub get_index { my ($a, $e) = @_; $e eq $a->[$_] and return $_ for 0..$#$a; return -1; }