in reply to perl script to calculate beg and end of current month

Dates are easy. Either you want to find all the records relative to the current date (next 30 days, for instance), in which case you can just store a timestamp with each record and then check that timestamp against the current timestamp:
my $mtime = time(); if ($rtime < $mtime + 86400 * 30) { ## Do whatever processing }
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:
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