In my Perl code, I need to copy a directory from one location to another on the same host excluding some files/patterns (e.g. *.log, ./myDir/abc.cl). What would be the optimum way of doing this in Perl across all the platforms? On Windows, xcopy is one such solution. On unix platforms, is there a way to do this in Perl?
+2
A:
I'd use File::Find
, and step over each file, but instead of calling File::Copy
's copy()
on each file, first test to see if it matches the pattern, and then next
if it does.
Nate
2010-03-22 11:56:31
+4
A:
I think you're looking for rsync. It's not Perl, but it's going to work a lot better than anything you make in Perl.
brian d foy
2010-03-22 15:34:53
+1
A:
On *nix, you can use native tar command, with -exclude options. Then after creating the tar file, you can bring it over to your destination to untar it.
ghostdog74
2010-03-22 15:54:33