file copy

P

Peter Sakalaukus

Is there a way to copy files on a unix machine where I can preserve
mode/ownership/timestamp info (as cp -p does)? I have looked in the
Camel book and the manpage but there does not seem to be ...


Thanks in advance ...Pete
 
P

Paul Lalli

Peter Sakalaukus said:
Is there a way to copy files on a unix machine where I can preserve
mode/ownership/timestamp info (as cp -p does)? I have looked in the
Camel book and the manpage but there does not seem to be ...

Have a look at the module File::NCopy available on the CPAN. Make sure
you set the 'preserve' argument to 1.

(As a test, the following worked for me - the new file retained the
original's permissions and modification date)

#!/usr/bin/perl
use strict;
use warnings;
use File::NCopy;
my $file = File::NCopy->new('preserve'=>1);
$file->copy('test1.txt', 'test1.txt.bkp');

Paul Lalli
 
P

Peter Sakalaukus

Thanks Paul!


Have a look at the module File::NCopy available on the CPAN. Make sure
you set the 'preserve' argument to 1.

(As a test, the following worked for me - the new file retained the
original's permissions and modification date)

#!/usr/bin/perl
use strict;
use warnings;
use File::NCopy;
my $file = File::NCopy->new('preserve'=>1);
$file->copy('test1.txt', 'test1.txt.bkp');

Paul Lalli
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top