in reply to Function to replace a old file with newer version

There are non-Perl tools to do things like this, rsync for one-way and unison for two-way synchronization.

If you want to do it with Perl, File::Copy and the file test operators together with File::Find should do the trick.

  • Comment on Re: Function to replace a old file with newer version

Replies are listed 'Best First'.
Re^2: Function to replace a old file with newer version
by hiradhu (Acolyte) on Nov 25, 2008 at 10:58 UTC
    Thanks. I have to do this recursively hence looking for a perl function. I found File::Xcopy
    update|UD - copy files only if 1) the file exists in the target and 2) newer in time stamp
    http://search.cpan.org/~geotiger/File-Xcopy-0.12/Xcopy.pm#xmove($from,_$to,_$pat,_$par)
      I'm not familiar with unison, but it probably can use recursion. I know rsync definitely does. Use Perl if you want, but it's not the only language that allows utilities to be written that recur through directories. Several utilities already exist which do that.