Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: RFC: Array::GroupBy

by jdporter (Paladin)
on Jan 07, 2009 at 16:14 UTC ( [id://734659]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub find_groups(&\@)
    {
    ...
        \%groups
    }
    
  2. or download this
    my $groups_hr = find_groups { $_->{'name'} } @rows;
    
    ...
        print "$k\t" . @{$groups_hr->{$k}} . "\n";
    }
    
  3. or download this
    find_groups { join $;, @{$_}{qw( name game score )} } @rows;
    
  4. or download this
    find_groups {
        $_->{'name'} eq 'foo' ? 1 :
        $_->{'game'} =~ /bar/ ? 2 :
        $_->{'score'} >= 500  ? 3 : 0
    } @rows;
    
  5. or download this
    use List::Util qw( sum );
    
    ...
        print "$k\t$avg\n";
    }
    
  6. or download this
        map { $_->{'score'} } @rows
    

Log In?
Username:
Password:

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

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

    No recent polls found