in reply to cloning a directory tree

My first comment is that this does not work properly (or at all on Win32)

The problem is that $File::Find::name is the fullpath so if I try to clone say C:/Perl to C:/New mkpath is passed args like 'C:/New/C:/Perl/site/lib' which is not a valid path. You need to make the paths relative to $from. This will actually work and produce a clone where the new root $to contains exactly what $from does:

#!/usr/bin/perl -w use strict; use File::Find; use File::Path 'mkpath'; #usage dirtreeclone fromdir todir No trailing slashes my $from = shift || '.'; my $to = shift || "$0-tmp"; my @dirs; find (sub {push @dirs => $File::Find::name if -d},$from); foreach my $dir(@dirs){ $dir =~ s/^\Q$from\E//; mkpath("$to/$dir"); }

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print