Daniel David wrote at Thu, 25 Jul 2002 12:00:29 +0200:

> I couldn't seem to find a built-in function for finding the index of an element in 
>an array...so I
> wrote this one:
> ...
> 
> it works.... but somehow i feel there's a built in function for this

You could also exploit the List::Util module:

use List::Util qw/first/;

my @array = ('a' .. 'z');
my $element = 'q';

print first {$array[$_] eq $element} (0 .. $#array);


Greetings,
Janek

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to