Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
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-09-22 21:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (203 votes), past polls