Since your dates are already in a format that is easily sorted, just use a simple '>' comparison to the one week ago date value.
use DateTime; use strict; use warnings; my $oneweekago = DateTime->now()->subtract(days => 7)->strftime("%Y%m% +d"); while (<DATA>) { print if /(\d{8})/ && $1 > $oneweekago; } =prints abcd3.20110509-2345 =cut __DATA__ abcd1.20110429-2345 abcd2.20110502-2345 abcd3.20110505-2345 abcd3.20110509-2345
Update: Changed implementation from POSIX to DateTime per ikegami
In reply to Re: date as part of filename
by wind
in thread date as part of filename
by zac_carl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |