|use the CPAN
use File::NCopy qw(copy);
# we want to copy the directory recursively
# can also use references to file handles, this is for backward
# compatibility with File::Copy
# we don't specify \1 as the first argument because we don't want
# copy directories recursively
copy "*", "backup";
# the below are the default config values
$file = File::NCopy->new(
'recursive' => 0,
'preserve' => 0,
'follow_links' => 0,
'force_write' => 0,
'set_permission' => \&File::NCopy::u_chmod,
'file_check' => \&File::NCopy::f_check,
'set_times' => \&File::NCopy::s_times,
set_permission will take two file names, the original to get the
file permissions from and the new file to set the file permissions
file_check takes two parameters, the file names to check the file
copy from and the file to copy to. I am using flock for Unix
Default for this is \&File::NCopy::f_check. On Unix you can also
\&File::NCopy::unix_check. This one compares the inode and device
set_times is used if the preserve attribute is true. It preserves
the access and modification time of the file and also attempts to
set the owner of the file to the original owner. This can be usef
in a script used by root, though enyone can preserve the access an
modification times. This also takes two arguments. The file to ge
the stats from and apply the stats to.
On Unix boxes you shouldn't need to worry. On other system you ma
want to supply your own sub references.
$file = File::NCopy->new(recursive => 1);
$file = File::NCopy->new(u_chmod => \&my_chmod,f_check => \&my_fch
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||