11012014 11132014 10092014 09092014 11112015 01012015 04012015 01042011 10122014 #### ... use File::Path qw( rmtree ); use Date::Simple ('date', 'today'); ... my $dir = '/dir/'; opendir (DIR, $dir) or die "Couldn't open $dir directory, $!"; while (my $directories = readdir DIR) { next if $directories=~/^\./; my $dir_found = $directories; $dir_found =~s/(\d{2})(\d{2})(\d{4})/$3-$1-$2/; # Difference in days between the dates: if (date($dir_found) - date($months_ago); if($days_diff >= 60){ rmtree("$dir/$directories")|| die ("ERROR:::cant delete: $!"); } } closedir DIR;