Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: how do i find the index of a specific array value?

by I0 (Priest)
on Apr 26, 2001 at 10:03 UTC ( [id://75723]=note: print w/replies, xml ) Need Help??


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

You could use an index hash:
my @array = qw( your array here ); my $search = "array"; my %index; @index{@array} = (0..$#array); my $index = $index{$search}; print $index, "\n";
This is a win, for larger arrays, if you need to do multiple/many lookups while the array remains static.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-18 04:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found