Perl: Extracting date from file name and comparing with current date

I need to extract the date part from the file name (20080221 in this ex) and compare it with the current date and delete it, if it is a past date.

$file = exp_ABCD4_T-2584780_upto_20080221.dmp.Z

really appreciate any help.

thanks
mkneni

m/(\d+)\./

you can then use Date::Calc::Delta_Days to compare file date with today's date.

Thank you both. I am still lost. I am not talking about the mtime of the file. I need to extract date portion from the file name (which is in YYYYMMDD format) and compare it with the current date.

if ($friendly_dancing_file_name =~ m/(\d+)\./) {
  print "oh goody, looks like the file's date is $1\n";
  print "abort, return, continue, are you sure?\n";
  <>;
}

If you don't know any Perl and would like for someone to write the script for you for free, now would be a good time to let us know. Did you look at the Date module's documentation, the Perl FAQ, and the FAQ for these forums? Date calculations are a frequently recurring topic and most questions you could imagine have already been asked and answered thoroughly.