In the script, there are two variables produced from a regexp match against the current line in the access_log:

$new_ip
$user_agent

and one that is determined by a subroutine that looks for clues that the user_agent is a robot:

$user_type

This is the subroutine that builds the hash of hashes. It compares the $new_ip in the current line of the access_log with IPs already in the hash and updates the user_type/user_agent info if it finds a match and creates a new entry if it doesn't.

sub build_user_hash {
    foreach $existing_ip (%user_hash) {
        if ($existing_ip eq $new_ip ) {
                        $user_hash {$existing_ip} {user_type} = $user_type;
                        $user_hash {$existing_ip} {user_agent} = $user_agent;
                        return;
        }
    }
        $user_hash {$new_ip} {user_type} = $user_type;
        $user_hash {$new_ip} {user_agent} = $user_agent;
        $unique_ip_count++;
}

On Dec 11, 2004, at 4:12 PM, Lawrence Statton wrote:

What you are doing would be much clearer if you included actual code.
My instincts tell me you might be building your hash-of-hashrefs
incorrectly, which case my example here will be of no help to you.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to