in reply to Tailing the access log

As a follow up to what Masem proposed, this is a code snippet that I used to monitor my Squid cache performance:

#!/usr/bin/perl package DateParser; use Date::Manip; sub date_mangler { $arg = $_[0]; $times = $_[1]; $seconds_gm = time(); $some_day = localtime($seconds_gm); $parsed=&ParseDate($some_day); $epoch = &UnixDate($parsed,"%s"); if(not defined $times) { $times = 1; } if(not defined $arg) { $arg = 'default'; } if(($arg eq '-min') or ($arg eq '-MIN')){ $epoch -= ($times *60); } elsif(($arg eq '-hour') or ($arg eq '-HOUR')){ $epoch -= ($times * 3600); } elsif(($arg eq '-day') or ($arg eq '-DAY')){ $epoch -= ($times * 86400); } else { $epoch -= 86400; } return $epoch; } 1;

A little background: Squid uses epoch time (seconds since epoch) as the date format. Calling DateParser::date_mangler (I tried hard to think of a better name, I promise ;) gives you the minumum number of seconds for the date metric (minute, hour) passed in as a parameter.

Thereafter, simply pick all the lines that have a date stamp larger than the one returned from this function..
HTH, and as always, comments on code much appreciated..

Update:File::Tail is exactly what you want for your job, as noted by others. My procedure is used to do analysis on static files that have already been rotated.