tags:

views:

179

answers:

3

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
+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
+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