in reply to Re: Re: Parsing of the web log file, access_log
in thread Parsing of the web log file, access_log

I couldn't take the sub calculate_time as written. Below is a version w/ duplications reduced, does not solve the actual problem of printing data in the intervals (see OP).

# Jun 20 2003 - create hash w/ "map" instead of explicit creation my %MonthToNumber; @MonthToNumber{qw (Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)} = map { sprintf "%02d" , $_; } (1..12); my %NumberToMonth = map { $MonthToNumber{$_} => $_ } keys %MonthToNumber; sub calculate_time { my $get_sec = sub { my @time = reverse @{ parse_date($_[0]) }; return # second, minute, hour, day month year timelocal(@time[0..(scalar @time -3)] , $time[-2] -1 , $time[- +1]); }; my ($begin_sec , $end_sec) = ( $get_sec->($begin_time) , $get_sec->($dateproc) ); my $elapsed = $end_sec - $begin_sec; #printf "BEGIN: %s(%s) END: %s(%s)\nELAPSED: %s\n" # , $begin_sec , $begin_time # , $end_sec , $dateproc # , $elapsed; if ( $elapsed < $interval ) { push (my @visual_page_values, {$processed_visual_pages{$dateproc}} +); print "The End seconds are: $dateproc @{$processed_visual_pages{$ +dateproc}}\n"; } else { $begin_time = $dateproc; push (@final_visual_pages, $dateproc); print " Final Visual pages are: @final_visual_pages\n"; } } sub parse_date { my $date = shift; return [ ] unless defined $date; my ($day, $month, $year, $hour, $minute, $second) = split '[/:]' , $date; return [ $year , $MonthToNumber{$month} , $day , $hour , $minute , $second ]; }

Other Notes (Jun 20 2003):

Replies are listed 'Best First'.
Re: Re: Re: Re: Parsing of the web log file, access_log
by Andy61 (Initiate) on Jun 20, 2003 at 20:42 UTC

    Thanks for that input and the code. I am actually looking at solving the interval problem. As I mentioned, I am able to get the timestamps with their no. of occurrences

    I shall appreciate any help in solving the interval problem.

    Per the suggestion of other posts, I tried to download Date::Calc, but not able to successfully do a "make". Pl. see my post in the Notes section.