Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: How to join values of the same key that is an array of hashes?

by Anonymous Monk
on Jan 05, 2014 at 04:18 UTC ( #1069347=note: print w/replies, xml ) Need Help??


in reply to How to join values of the same key that is an array of hashes?

Or this:

use warnings; use strict; my %h; while (<DATA>) { my @cols = split; push @{ $h{ shift @cols } }, \@cols; } print $_, ' ', join( ' ' => map { $_->[0] } @{ $h{$_} } ), ' ', join( ' ' => map { $_->[1] } @{ $h{$_} } ), $/ for sort { $a cmp $b } keys %h; __DATA__ p1 cis 10 p1 plat 20 p1 gls NA p2 cis 0 p2 NA 9

  • Comment on Re: How to join values of the same key that is an array of hashes?
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1069347]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2016-12-03 16:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (56 votes). Check out past polls.