Last active
April 6, 2016 02:54
-
-
Save ess/cbb137541464e72080f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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