Lawrence (and all),
I haven't gotten a chance to dig into the examples and work on the
problem yet but I wanted to say thanks for the help.
For example: Is using the IP address as the key really a good idea?
Might an IP address be assigned to two different users -- or might a
person use two diffe
Jonathan,
That had occurred to me part way through writing the script. I'm
learning Linux, Apache, MySQL and Perl/PHP all at the same time so
sometimes I get halfway through a project in one area then learn
something new in another area that causes me to have to back the first
project and do a
James marks wrote:
Hello folks,
Hello,
I'm wondering if any of you could help me with a code problem? I'm
relatively new to Perl, coming to it from AppleScript, and I've written
a Perl script that parses my server access_log and creates a hash of
hashes that looks essentially like this:
192.168
> 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 bu
Dear James,
A way to work with that datastructure would be:
my %hash = ...;
my @robots;
for my $ip (keys %hash) {
my $type = $hash{$ip}{type};
push @robots, [ $ip, $hash{$ip}{agent} ] if $type eq "robot";
}
I suggest you use an array of hashes, in the form:
my @array = (
{ ip => .
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. I
> Hello folks,
>
> I'm wondering if any of you could help me with a code problem? I'm
> relatively new to Perl, coming to it from AppleScript, and I've written
> a Perl script that parses my server access_log and creates a hash of
> hashes that looks essentially like this:
>
> 192.168.1.1 =
>
> > I want to traverse that hash of hashes to extract the user agent of
> > each IP whose user type is "robot" like this:
>
D'OH! I just re-read the problem ...
amend to read
print "$key \"$log{$key}{user_agent}\"\n"
if $log{$key}{user_type} eq 'robot';
-- -- -- -- -- -- -- --
On Sat, 11 Dec 2004 15:58:48 -0800, James marks wrote:
> I want to traverse that hash of hashes to extract the user agent of
> each IP whose user type is "robot" like this:
>
> LIST OF ROBOTS VISITING SITE:
> 192.168.1.1 "...GoogleBot..."
> 192.168.1.4 "...Yahoo! Slurp..."
> etc...
#!/usr/local/b
Hello folks,
I'm wondering if any of you could help me with a code problem? I'm
relatively new to Perl, coming to it from AppleScript, and I've written
a Perl script that parses my server access_log and creates a hash of
hashes that looks essentially like this:
192.168.1.1 =
10 matches
Mail list logo