in reply to Any hints on how to do this?
use strict; use warnings; my %seen = (); print map {sprintf qq{%-7s%2d\n}, @$_} map {[$seen{$_->[0]} ++ ? q{} : $_->[0], $_->[1]]} map {[split]} <DATA>; __END__ GEORGE 21 GEORGE 45 NICK 12 PETER 27 JIM 18 JIM 87 CHRIS 33
and when run, it produces
GEORGE 21 45 NICK 12 PETER 27 JIM 18 87 CHRIS 33
If your names were not already grouped you could insert a sort like this
print map {sprintf qq{%-7s%2d\n}, @$_} map {[$seen{$_->[0]} ++ ? q{} : $_->[0], $_->[1]]} sort {$a->[0] cmp $b->[0]} map {[split]} <DATA>;
I hope this is of use.
Cheers,
JohnGG
|
|---|