Here,
The first statement in the sub checks for the proper number of arguments. The second returns success without doing anything if the target exists and is newer than the source (by mtime). If that didn't happen, &File::Copy::copy is called on the arguments and its result returned.use File::Copy; sub ucopy { @_ == 2 or die 'sub ucopy needs two arguments.'; -e $_[1] and (stat $_[1])[9] > (stat $_[0])[9] and return 1; copy @_; }
After Compline,
Zaxo
In reply to Re: Duplicating the 'cp' command's '-u' switch
by Zaxo
in thread Duplicating the 'cp' command's '-u' switch
by nysus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |