FWIW, my reusable code would probably look like:

package Directory::Copy;
use strict;
use File::Copy;
use File::Find;
use File::Path;

sub copy_path {
        my($origpath, $destpath) = @_;

        find(sub {
                my($file) = $File::Find::name;
                (my $dest = $file) =~ s/^\Q$origpath/$destpath/;
                if (-d $file) {
                        mkpath $dest;
                } elsif (-f $file) {
                        copy $file, $dest;
                }
        }, $origpath);
}

__END__

As Bart noted, the /o is not really necessary, nor is a string eval.  Even
if it were a performance hit, I'd prefer to ignore it in most code, as the
performance hit is probably less severe than the more work and less
readability of dealing with it.  In a module on CPAN, such optimizations
would probably be worth it, esp. for older Perls, though.

-- 
Chris Nandor                      [EMAIL PROTECTED]    http://pudge.net/
Open Source Development Network    [EMAIL PROTECTED]     http://osdn.com/

Reply via email to