in reply to Extracting date encodings from a filename... is my regex-based function correct?

If you can give us better specs, we can probably whip something out for you (though, to be fair, date matching is a much harder problem than it appears, if there is a great danger of similar numbers.

My guess is that you have a two digit year, followed by a two digit month and a two digit day, but I'm not sure about the rest of the numbers or whether or not the letters (such as nasd) will change. If you wish, you can build that date substring by using localtime. This will simplify the regex.

my ($day, $month, $year) = (split (/\s|:/, localtime))[2,3,6]; $year = substr $year, 2,2; my $date = $year . $month . $day;
This assumes that you always need files with todays date stamp. You'll need to modify it to fit your particular needs.

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just go the the link and check out our stats.