Skip to content

Instantly share code, notes, and snippets.

@ahushh
Created December 17, 2014 11:28
Show Gist options
  • Save ahushh/55f646b818fb76485526 to your computer and use it in GitHub Desktop.
Save ahushh/55f646b818fb76485526 to your computer and use it in GitHub Desktop.
yoba
use v5.16;
use File::Copy qw/move copy/;
my $f = 'yoba';
my $t = 'yoba2';
my @queue = ($f, $t);
while (@queue) {
my $from = shift @queue;
my $to = shift @queue;
say "Current dir is $from";
opendir(my $hfrom, $from);
mkdir "$to";
say "Creating dir $to";
while (readdir $hfrom) {
if (/(?:\.)|(?:\.\.)/m) {
next;
}
if (-d "$from/$_") {
push @queue, "$from/$_";
push @queue, "$to/$_";
} else {
#move("$from/$_", "$to/$_");
#say "Moving $from/$_ $to/$_");
copy("$from/$_", "$to/$_");
say "Copying '$from/$_' '$to/$_'";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment