in reply to Help with calculating stats from a flat-file database
MYHANDLE can be replaced with the handle of your flat file after you open it.foreach (<MYHANDLE>) { $_ =~ /^(\d+)\/(\d+)\/(\d+)\t(\d+)\t/; if (!$h{"$1$2$3$4"}) { $h{"$1$2$3$4"} = 1; $c{$3}{$4}++; } } foreach $year (sort keys %c) { print "$year\n"; $p = $c{$year}; foreach (sort {$a <=> $b} keys %$p) { print "$_ " . $c{$year}{$_} . "\n"; } print "\n"; }
|
|---|