How do I best compare mtime of several files. I have a script for making
daily backups into a given directory. Now I want to modify it to
delete old backups if the total exceed cetain number.
The idea was to compare the mtime of all file to figure out old files to
delete, but somehow I think it shouldn't be all that complicated.
Any elegant idea on how to acomplice this?
Thanks
mtimes are just integers, so you can compare them with the normal math operators. Theoretically you can open a directory, list the files, read the mtimes with c<stat> into a hash with file/mtime structure. Then just sort the hash by the mtime, and remove any files beyond your desired threshold.
What have you tried? Where did you fail?
perldoc -f opendir perldoc -f readdir perldoc -f unlink perldoc -f stat perldoc -f sort
Those 5 functions should get you started...
http://danconia.org
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>