|
|
|
#!/usr/local/bin/perl -w
use strict;
use Data::Dumper;
@ARGV = qw(fruitbowl.log);
my(%tally, %dates, %fruits);
while (<>) {
chomp;
my($date, $time, $fruit) = split(/ /);
$tally{$date}->{$fruit}++;
$dates{$date} = undef;
$fruits{$fruit}++;
}
#print Dumper(\%tally);
my @names = sort(keys(%fruits));
printf("Date " . " %9s" x @names . "\n", @names);
foreach my $date (sort(keys(%dates))) {
my %daytally = %{$tally{$date}};
local($^W) = 0; # Turn off -w just for next line
printf($date . " %9u" x @names . "\n", @daytally{@names});
}
printf("Totals: " . " %9u" x @names . "\n", @fruits{@names});
|
|
|
|
|