On Thu, 22 Jan 2009 17:16:00 -0500 "Li, Aiguo (NIH/NCI) [E]" <l...@mail.nih.gov> wrote:
> Hi all, > > > > I need copy files from a directory daily to a folder. How can I > select files based on dates that were created? It will depend on the file naming format, for example, if the files are named 20090123.blah.bz2, then you could collect all those files out of the directory with something like; opendir( DB_DIR, $db_dir ); # where $db_dir has been assigned earlier my @files = grep { /\d{8}/ } readdir(DB_DIR); You might then want to do the same for the receiving directory and then read FAQ4.41 "How can I remove duplicate elements from a list or array' and adapt with File::Copy to do the copy bit. However I wouldn't bother with perl in this case, simply use rsync in a cron job to update your copy directory. Owen -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/