in reply to Re^3: Adding data to hashes & comparing
in thread Adding data to hashes & comparing
foreach (@get_logs) { @get_array = &logToHash($_); } foreach(@get_array) { print Dumper($_); } sub logToHash { my $file = $_; my @AoH; open LOG, $file or die $!; our ($aRequests,$ip,$userAgent,$date,$hRequests,$host); while ( my $line_from_logfile = <LOG> ) { eval { %data = $lr->parse($line_from_logfile); }; if (%data) { # We have data to process while( my ($key, $value) = each(%data) ) { if($key =~ '%h') { ($host,$ip) = split(/:/, $value); } if($key =~ '%{User-Agent}i\""') { $userAgent = $value; } if($key =~ '%t') { $date = $value; } } $aRequests = $hRequests{$ip}{$userAgent}{$date}; push @$aRequests, \%data; } } return @$aRequests; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Adding data to hashes & comparing
by ELISHEVA (Prior) on Mar 31, 2009 at 17:56 UTC |