You would have to 'walk' the whole array, which is rather inefficient. However, depending on what else you need to do with your data, a hash could do better than an array:

%myhash = ('abc'=>1, 'xyz'=>2, 'mno'=>3, 'pqr'=>4, 'stu'=>5, 'sdfd'=>6);

and then

$myhash{ 'pqr') wiil return 4.

- Richard


Mallik wrote:

I need to find the index of a particular element in array.

For eg.,
@arr = ('abc', 'xyz', 'mno','pqr','stu','sdfd');

I want to find the index of the element 'pqr' which is 4.

Any function/code to achieve this.

Thanks in advance,
Mallik.



-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to