Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2016-12-10 12:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (162 votes). Check out past polls.