in reply to Re^2: Adding data to hashes & comparing
in thread Adding data to hashes & comparing
my $IP = #extract from %data; my $userAgent = #extract from %data; my $date = #extract from %data; my $aRequests = $hRequests{$IP}{$userAgent}{$date}; push @$aRequests, \%data;
Then after you have read in all the requests, loop through %hRequests using the hash keys to select the requests that interest you. The pseudo code would look something like this:
while (my ($IP, $hUserAgents) = each(%hRequests)) { next if #IP is boring; while (my ($userAgent, $hDates = each(%$hUserAgents)) { next if #user agent is boring; while (my ($date, $aRequests) = each(%$hDates)) { #do something if date is in range #wanted for $IP, $userAgent } } }
There's a lot of work navigating references to hashes and arrays here. As moritz said previously, studying perldata, perlref (or perlreftut) and perldsc might be well worth your time.
Best, beth
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Adding data to hashes & comparing
by hallikpapa (Scribe) on Mar 31, 2009 at 14:36 UTC | |
by ELISHEVA (Prior) on Mar 31, 2009 at 17:56 UTC |