Okay so I'm still wrestling with these log files. What I'm trying to do now is get it to go through and add up how long a user stayed on a page. The log is formatted like this:
19.33.44.63 2003/08/05 0009:38:11 PASSED 110.25.12.6 2003/08/05 0009:38:11 PASSED 101.59.34.99 2003/08/05 0010:42:53 PASSED 210.6.13.3 2003/08/05 0010:42:54 PASSED
The above times are the real times from the log. Now I try running this script on it (my first actual script since finishing Perl for Dummies, be gentle, lol):
I think I'm 50/50 on the right track, but I know something is wrong (other than just by looking at it) because I get this for output:
I welcome any and all help with this
19.33.44.63 2003/08/05 0009:38:11 PASSED 110.25.12.6 2003/08/05 0009:38:11 PASSED 101.59.34.99 2003/08/05 0010:42:53 PASSED 210.6.13.3 2003/08/05 0010:42:54 PASSED
The above times are the real times from the log. Now I try running this script on it (my first actual script since finishing Perl for Dummies, be gentle, lol):
Code:
#Declare and localize the variables
my %Time;
my $User;
my $Dd;
my $Tt;
my $Ap;
my $Dest;
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst);
#Open the text file
open(INDB, "d:\\perl\\test.txt") or die "Can't do it.";
#Begin a loop
while(<INDB>) {
time;
$Line = $_;
($User, $Dd, $Tt, $Ap, $Dest) = split(/\s/, $Line);
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime($Tt);
$Elapsed = ($hour, $min, $sec);
if(exists $Time{$Elapsed}) {
$Time{$Elapsed} += 1;
}#End of if
else {$Time{$Elapsed} = 1}#End of else
}#End of while
foreach $key( %Time) {
print "Total time elapsed is $key. \n";
}
I think I'm 50/50 on the right track, but I know something is wrong (other than just by looking at it) because I get this for output:
Code:
Total time elapsed is 10.
Total time elapsed is 2.
Total time elapsed is 9.
Total time elapsed is 2.
I welcome any and all help with this