Hi, I am trying to write a small Perl program to produce a custom report from my weblogs. I have mostly managed it, but am really stuck with using multidimensional hashes. I just can't seem to get it right :-(
 
I am reading one line of data from the file at a time & have a while loop with all of the various processing loops running inside this.
 
I am trying to store for each unique IP, which pages they visited & how many times they visited each page. And then to print this info. I have tried various combinations & methods (for hours over the past 2 days), but with no success, it prints blank, so I think that either I'm not storing the data correctly or I'm not accessing it correctly or both.
 
I have tried various combinations of the following.
 
$page & $ip both contain the correct data as they produce correct results in other parts of the report.
 
%pagecount = ();
 
if($pagecount{$page}{$ip}){
    $pagecount{$page}{$ip}++;
} else {
    $pagecount{$page}{$ip} = 1;
}
 
for $ipaddress (keys %pagecount){
    print "$ipaddress visited ";
    for $pagevisited(keys %{pagecount{$ipaddress}}){
        print "$pagevisited $pagecount{$ipaddress}{$pagevisited} times";
    }
}
 
 
I am using ActivePerl 5.6 on Windows98.
 
Can anyone please tell me where I am going wrong?
Many Thanks
 
Karl :-)

Reply via email to