First, I would urge you to read Mark Jason Dominus's
argument against symbolic references, it is pure wisdom.
Your suggested solution of using a hash is a very good one:
my @now = localtime( time );
my %container; # use this rather than a symbolic ref
foreach my $line ( @data ) {
my ( $timestamp, $page, $moredata ) = split /|/, $line;
my @hits = localtime( $timestamp );
$container{$page}[0]++ if $hits[7] == $now[7];
$container{$page}[1]++ if $hits[4] == $now[4];
$container{$page}[2]++ if $hits[5] == $now[5];
$maxCount{$page}++;
}
my @pages = keys %maxCount;
my ( @dAry, @wAry, @mAry );
foreach my $page ( keys %maxCount ) {
push @dAry, $container{$page}[0];
push @wAry, $container{$page}[1];
push @mAry, $container{$page}[2];
}
my $dAry = join ',', @dAry;
my $wAry = join ',', @wAry;
my $mAry = join ',', @mAry;
Note that other monks may have advice about a better way to code what you are doing; I just wanted to show you how it could be rephrased to run under
strict and be a little more idiomatic with minimal changes. Note that I use a
join to create the three strings at bottom - this eliminates the trailing comma problem.
Also, note that you can group
my declarations in parentheses, minimizing visual clutter.
I hope this is at least a start - kudos for turning on
strict, for all the hassle at first, you'll find it saves you invaluable hassle down the line, when you make a typo in the middle of a thousand lines of code.
Good luck!