nedals has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; my $datafile = "data.txt"; my @now = localtime(time); open(FIL,"<$datafile") or die "Can't open data file: $!\n"; my @data = <FIL>; close(FIL); my %maxCount; foreach my $line (@data) { (my $timestamp, my $page, my $moredata) = split('\|',$line); my @hits = localtime($timestamp); # Here I create and preset an array with a variable name defined b +y $page @$page = (0,0,0,0) if ($$page[3] eq ''); if ($hits[7] == $now[7]) { $$page[0]++; } if ($hits[4] == $now[4]) { $$page[1]++; } if ($hits[5] == $now[5]) { $$page[2]++; } $maxCount{'$page'}++; } my @pages = keys %maxCount; # Gets list of page names my $dAry = ""; my $wAry = ""; my $mAry = ""; foreach my $page (@pages) { $dAry .= "$$page[0],"; $wAry .= "$$page[1],"; $mAry .= "$$page[2],"; } #... continued exit;
Is it possible to have for a hash array element contain a list array? (a possible solution)
Thanks in advance....
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problems with 'strict' and variables created on the fly
by tadman (Prior) on Nov 11, 2002 at 03:12 UTC | |
|
Re: Problems with 'strict' and variables created on the fly
by FamousLongAgo (Friar) on Nov 11, 2002 at 03:23 UTC | |
|
Re: Problems with 'strict' and variables created on the fly
by graff (Chancellor) on Nov 11, 2002 at 03:31 UTC | |
|
Re: Problems with 'strict' and variables created on the fly
by BrowserUk (Patriarch) on Nov 11, 2002 at 03:26 UTC | |
|
Re: Problems with 'strict' and variables created on the fly
by Notromda (Pilgrim) on Nov 11, 2002 at 03:17 UTC | |
|
Re: Problems with 'strict' and variables created on the fly
by pg (Canon) on Nov 11, 2002 at 03:23 UTC | |
|
Re: Problems with 'strict' and variables created on the fly
by nedals (Deacon) on Nov 11, 2002 at 20:36 UTC |