in reply to Group 2d array
#!/usr/bin/perl -w use strict; my %gbhash; open(DATA, '/usr/local/fun/data.txt') or die $!; while (<DATA>) { chomp; my ($key,$val) = split; if (exists $gbhash{$key}) { $gbhash{$key} = $gbhash{$key} . '-' . $val; } else { $gbhash{$key} = $val; } } close DATA; #Now print em foreach my $skey (sort {$a<=>$b} keys %gbhash) { print "$skey $gbhash{$skey}\n"; } ------ DATA (data.txt): 1 0 1 1 2 0 3 1 4 3 4 6
|
|---|