Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Getting indices of the same value that occurs multiple times in an array...

by moritz (Cardinal)
on Aug 04, 2011 at 11:39 UTC ( #918509=note: print w/ replies, xml ) Need Help??


in reply to Getting indices of the same value that occurs multiple times in an array...

Try something like

my @indexes = grep { $a[$_] eq $search_for } 0..$#a; $participants{$og} = \@indexes;

This puts an array reference of all found indexes into the hash. See perlreftut for more information about references, and why you need them here.


Comment on Re: Getting indices of the same value that occurs multiple times in an array...
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2015-07-05 06:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls