Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: How do I find the index of a specific array value?

by marcussen (Pilgrim)
on Jul 25, 2008 at 03:16 UTC ( [id://700018]=note: print w/replies, xml ) Need Help??


in reply to How do I find the index of a specific array value?

Using merlyn's example with regular expressions, so you don't need to know the exact value of the element you are matching;

my @array = ( 'Name: Mr. Jones', 'Phone: 555-555', 'Email: jones@example.com' ); my ( $index )= grep { $array[$_] =~ /Phone/ } 0..$#array;
Replace ( $index ) with an array to match multiple instances.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://700018]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-03-28 14:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found