and that's the script:
open(db, "data.log");
while(<db>)
{
(my $data, my $count) = split(/ ~ /, $_);
my $table{$data} = chomp($count);
}
close(db);
the error occurs in the line where the hash gets the data, but there ain't no helpfull error message :(
i really wonder what i did wrong?
any help appreciated,
thanks in advance :)
this is the script so far:
#!perl
use strict;
use CGI::Carp qw(fatalsToBrowser);
print "Content-type: text/plain\n\n\n";
my $ua ="Opera/5.01 (Windows NT 5.0; U) [en]";
my %table;
open(db, "data.log");
while(<db>)
{
(my $data, my $count) = split(/ ~ /, $_);
$table{$data} = $count;
}
close(db);
print "UA:",$table{$ua},"\n";
print "EXST:",exists($table{$ua}),"\n";
print %table;
in the end i wanted to count how often the different browsers access the site.
however, the string is not found, although %table contains it...
the output looks like this:
UA:
EXST:
Mozilla/5.0 (Windows 98; U) Opera 5.12 [en]1
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Q312461)1
Mozilla/4.0 (compatible; MSIE 5.0; Windows NT 5.0) Opera 5.01 [en]1
Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)1
Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)1
[...]
why isn't the string found in the hash?
else
{my %table;
open(db, "useragent.log");
while(<db>)
{chomp;
(my $data, my $count) = split(/ ~ /, $_);
$table{$data} = $count;}
close(db);
$table{$ua}++;
my @entries = keys(%table);
@entries = sort(@entries);
open (db, "> useragent.log");
foreach(@entries)
{print (db "$_ ~ $table{$_}\n");}
close(db);}}