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

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

by thenaz (Beadle)
on Aug 04, 2011 at 12:20 UTC ( #918512=note: print w/ replies, xml ) Need Help??


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

Here is what I would do (save you a loop).

my %og_to_gid; foreach (@COUNT) { my @a = split /\s+/; my $og = $a[0]; my $search_for = "1"; my @indices = grep { $a[$_] eq $search_for } 0..$#a; $og_to_gid{$og} = join ' ', map { $families[$_] } @indices; }


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://918512]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2014-12-20 16:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (96 votes), past polls