Hi Mallik
You can use regular expression

-----------------
$i=0;
 foreach $temp (@arr)
  {
    if ( $temp eq 'pqr' )
     {
       print "index is == $i \n";
       last;
      }
    $i++;
   }
---------------------
I hope this will work ,but ur desired index is 3 not 4.

Mallik ..

Deserve before you desire







-----Original Message-----
From: Mallik [mailto:[EMAIL PROTECTED]
Sent: Thursday, January 27, 2005 12:56 PM
To: Perl-Trolls
Cc: beginners@perl.org
Subject: How to find the Index of an element in array?


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>





Confidentiality Notice

The information contained in this electronic message and any attachments to 
this message are intended
for the exclusive use of the addressee(s) and may contain confidential or 
privileged information. If
you are not the intended recipient, please notify the sender at Wipro or [EMAIL 
PROTECTED] immediately
and destroy all copies of this message and any attachments.

--
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