in reply to perl script to calculate beg and end of current month
Or you want to find all records within an exact date range, in which case you just store the dates in fixed-width, greatest significance first numerical format and test as necessary:my $mtime = time(); if ($rtime < $mtime + 86400 * 30) { ## Do whatever processing }
use strict; use warnings; my ($sdate, $edate, $rdate); $sdate = sprintf('%04d%02d%02d', 2006, 11, 4); $edate = sprintf('%04d%02d%02d', 2006, 12, 4); while (<DATA>) { ($rdate) = m/(\d+)/; print if $sdate <= $rdate && $rdate <= $edate; } __DATA__ 20061203 Record 1 20061204 Record 2 20061206 Record 3
|
|---|