use strict;
use warnings;
cleanup("d:/tempo");
sub cleanup {
my $dir = shift;
local *DIR;
opendir DIR, $dir or die "opendir $dir: $!";
for (readdir DIR) {
next if /^\.{1,2}$/;
my $path = "$dir/$_";
unlink $path if -f $path;
cleanup($path) if -d $path;
print "deleting $path\n";
}
closedir DIR;
print "Deleting $dir";
rmdir $dir or print "error - $!";
use warnings;
cleanup("d:/tempo");
sub cleanup {
my $dir = shift;
local *DIR;
opendir DIR, $dir or die "opendir $dir: $!";
for (readdir DIR) {
next if /^\.{1,2}$/;
my $path = "$dir/$_";
unlink $path if -f $path;
cleanup($path) if -d $path;
print "deleting $path\n";
}
closedir DIR;
print "Deleting $dir";
rmdir $dir or print "error - $!";
No comments:
Post a Comment