#!/usr/bin/env perl use strict; use warnings; use feature 'say'; use DateTime; my $date_in = "myfile-b2291ce2b21d1cf6f6af68bd3e355505-20120112T115534"; my ($year, $month, $day ) = $date_in =~ m| myfile- .* - ( \d{4} ) ( \d{2} ) ( \d{2} ) T \d{6} |x; my $now = DateTime->now; my $record = DateTime->new( year => $year, month => $month, day => $day, ); my $duration = $now->delta_days($record)->in_units('days'); #just reporting stuff to make sure all is well say "Now is: $now"; say "The record was: $record"; say "The record is $duration days old..."; say "Too old!" if $duration > 30;