Given the data is ordered as you show, this should do what you want:
my %data; while (<DATA>) { chomp($_); my ($first, $second) = split(/\s+/, $_); push(@{$data{$first}}, $second); } foreach my $first (sort {$a <=> $b} keys %data) { print "$first ", join('-', @{$data{$first}}), "\n"; }
Hope this helps, -gjb-
In reply to Re: Group 2d array
by gjb
in thread Group 2d array
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |