Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Check if "System" was succesful

by JSchmitz (Canon)
on Apr 09, 2004 at 13:50 UTC ( #343907=note: print w/replies, xml ) Need Help??


in reply to Check if "System" was succesful

use the CPAN
use File::NCopy qw(copy); copy "file","other_file"; copy "file1","file2","file3","directory"; # we want to copy the directory recursively copy \1,"directory1","directory2"; copy \1,"file1","file2","directory1","file3","directory2","file4", "directory"; # can also use references to file handles, this is for backward # compatibility with File::Copy copy \*FILE1,\*FILE2; copy \*FILE1,"file"; copy "file1",\*FILE2; # we don't specify \1 as the first argument because we don't want +to # copy directories recursively copy "*.c","*.pl","programs"; copy "*", "backup"; use File::NCopy; # 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 for. file_check takes two parameters, the file names to check the file +to copy from and the file to copy to. I am using flock for Unix systems. Default for this is \&File::NCopy::f_check. On Unix you can also +use \&File::NCopy::unix_check. This one compares the inode and device numbers. 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 +ul in a script used by root, though enyone can preserve the access an +d modification times. This also takes two arguments. The file to ge +t the stats from and apply the stats to. On Unix boxes you shouldn't need to worry. On other system you ma +y want to supply your own sub references. $file = File::NCopy->new(recursive => 1); $file->copy "file","other_file"; $file->copy "directory1","directory2"; $file = File::NCopy->new(u_chmod => \&my_chmod,f_check => \&my_fch +eck); $file->copy "directory1","directory2";

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://343907]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2020-11-30 14:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?