Question: My webapp is hosted on a unix server using MySQL as database.

I wrote a Perl script to run backup of my database. The Perl script is inside the *cgi-bin* folde and it is working. I only need to set the cronjob and run the Perl script once a day.

The backups are stored in a folder named *db\_backups*,. However, I also want to add a command inside my Perl script to remove any files inside the folder *db\_backups* that are older than say 10 days ago.

I have searched high and low for unix commands and cannot find anything that matches what I needed.

Answer: 
`if (-M $file > 10) { unlink $file }`

or, coupled with `File::Find::Rule`

```
my $ten_days_ago = time() - 10 * 86400;
my @to_delete = File::Find::Rule->file()
  ->mtime("<=$ten_days_ago")
  ->in("/path/to/db_backup");
unlink @to_delete;

```
On Unix you can't, because *the file's creation date is not stored in the filesystem*.

You may want to check out [stat](http://perldoc.perl.org/functions/stat.html), and [-M](http://perldoc.perl.org/functions/-X.html) (modification time)/[-C](http://perldoc.perl.org/functions/-X.html) (*inode change time*)/[-A](http://perldoc.perl.org/functions/-X.html) (access time) if you want a simple expression with relative timestamps (how long ago).