Seems like you could use stat on each file and compare the mtime with time() - (86400 * 30) (or whatever). There is even File::stat which gives you a nice readable interface to the stat() attributes.
No good deed goes unpunished. -- (attributed to) Oscar Wilde