Skip to content

Instantly share code, notes, and snippets.

@ess
Last active April 6, 2016 02:54
Show Gist options
  • Save ess/cbb137541464e72080f6 to your computer and use it in GitHub Desktop.
Save ess/cbb137541464e72080f6 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use Cwd;
use File::Path;
my $tree = $ARGV[0];
sub saw ($) {
my($leaf) = @_;
my $cwd = getcwd;
chdir $leaf;
printf "Traversing %s ...\n", getcwd;
unlink(glob("*"));
my @dirs = glob("*");
foreach $dir (@dirs) {
saw($dir);
}
chdir $cwd;
}
saw($tree);
rmtree($tree);
#!/usr/bin/perl
use Cwd;
use File::Path;
my $tree = $ARGV[0];
die "$tree does not exist or cannot be processed\n" unless ( -d $tree );
sub saw ($) {
my($leaf) = @_;
my $cwd = getcwd;
chdir $leaf;
printf "Traversing %s ...\n", getcwd;
unlink(glob("*"));
my @dirs = glob("*");
foreach $dir (@dirs) {
saw($dir);
}
chdir $cwd;
}
saw($tree);
rmtree($tree);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment