use strict; use warnings; my $time = time(); my $days = 45; my ($day, $mon, $mday, $hour, $min, $sec, $zone, $year, $depth, $flag) +; while (read(DATA, $_, 45)) { if (!$flag) { ($day, $mon, $mday, $hour, $min, $sec, $zone, $year, $depth) = unpack('A3xA3xA2xA2xA2xA2xA3xA4x14A3', $_); # Use module to convert to timestamp $mytime if ($mytime > $time - 86400 * $days) { print $depth; $flag = 1; } } else { ($depth) = unpack('x42A3', $_); print $depth; } } __DATA__ Fri Dec 3 23:07:21 EST 2004 : Depth is : 234Sat Dec 4 00:07:29 EST 2 +004 : Depth is : 123Sat Dec 5 03:07:32 EST 2004 : Depth is : 144
Problem is, I don't know a good module for creating a timestamp out of the date information. Maybe someone else can insert that part for me?
In reply to Re: grep for last 45 days
by TedPride
in thread grep for last 45 days
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |