Perl-only solution:
#!/usr/bin/perl -w use strict; ${^WIN32_SLOPPY_STAT}++; # Speed up the 'stat' call on Windows if ((stat "/tmp/A")[9] > (stat "/tmp/B")[9]){ # Compare mtime stamps print "A is newer than B; discarding B.\n"; unlink "B" or die "B: $!\n"; } else { print "B is newer than A; replacing A.\n"; unlink "A" or die "A: $!\n"; rename "B", "A" or die "Copying B->A: $!\n"; }
In reply to Re: Function to replace a old file with newer version
by oko1
in thread Function to replace a old file with newer version
by hiradhu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |