in reply to Week Algorithm

In your example, 7-26-03 (the beginning of your example regex range) is a Saturday, so I don't really understand if it's relevant that weeks for you go from Monday to Sunday. Anyway, it's not that hard to generate a list of valid dates and then combine those into a regex string that you can plop right into your matching code. Here's a little bit of code to get you started:
use Time::Local 'timelocal_nocheck'; my ($m, $d, $y) = (8, 1, 2003); ## list dates between 0 and 6 days ago: my @dates; for my $days_ago (0 .. 6) { my @date_info = localtime timelocal_nocheck(0, 0, 0, $d-$days_ago, $ +m-1, $y-1900); push @dates, sprintf("%s-%s-%s", $date_info[4]+1, $date_info[3], $date_info[5]+1900); } ## convert list of dates to a regex my $regex = join "|", map quotemeta, @dates; print "$regex\n"; ## now you can do stuff like; ## if ($line =~ /^($regex)/) { ## print "this happened last week ($1)\n"; ## } __END__ 8\-1\-2003|7\-31\-2003|7\-30\-2003|7\-29\-2003|7\-28\-2003|7\-27\-2003 +|7\-26\-2003
This seems to output pretty much what you wanted, at least for 8-1-2003. If you're not familiar with Time::Local's timelocal_nocheck function, you should really take a look at it to see what the heck is going on here.. And if you really need these ranges to be aligned to your Mon-Sun weeks, you can calculate how many days to back up based on what day of the week today is (info you can get from localtime).

Unlike the other repliers, I prefer using Time::Local's timelocal_nocheck for date calculations whenever I can, because Time::Local is a standard module, and much much less overhead than Date::Calc or Date::Manip. It sometimes takes a little bit more work on your end to use Time::Local for date calculations. But I don't think you will find a pre-packaged solution for your problem anywhere, so elbow grease can't be avoided here. In this case, just subtracting days is a piece of cake for timelocal_nocheck. Rarely do I ever need to do computations that are whacked-out enough (or thousands of years away from the present) to require the heavy-duty modules.

blokhead