use strict; use warnings; my %res; while (<DATA>) { my ( $name, $weight ) = split /\s+/; push @{ $res{$name} }, $weight; } for ( sort keys %res ) { print "$_ ", join( ",", @{ $res{$_} } ), "\n"; } __DATA__ jim 14 john 23 ernest 38 matilda 43 jim 34 ernest 27 john 44 matilda 22
In reply to Re: How can I group lines in a file?
by zwon
in thread How can I group lines in a file?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |