wufnik has asked for the wisdom of the Perl Monks concerning the following question:
now, run this through cygwin perl (5.8.2), using something like# rmdirsimple.pl use File::Find qw(finddepth); use Cwd; *name = *File::Find::name; my @dirs = @ARGV; my @legitdirs = grep { -d } @dirs; finddepth (\&unlinkplus, @legitdirs); # danger, danger. high voltage. use at own risk. sub unlinkplus { warn "current dir :" . cwd . "\n"; if (!-l && -d _) { # not a link, is a directory warn "rmdir attempt :" . $name . "\n"; (rmdir($_) && warn "ok..." ) or warn "cannot rmdir $name:" . " $!"; } else { warn "file unlink :" . $name . ">"; (unlink($_) && warn "ok..." ) or warn "can't unlink " . $name . "$!"; } }
where a and b are directories that contain a.txt and b.txt respectively, and you will get a satisfying:/usr/bin/perl rmdirsimple.pl a b
run it through activestate (5.6.1) perl - and the deletion of the directories seems impossible: here's the results:current dir :/home/k/kh/prlfrg/dat/a file unlink :a/a.txt> at rmdirsimple.pl line 20. ok... at rmdirsimple.pl line 21. current dir :/home/k/kh/prlfrg/dat/a rmdir attempt :a ok... at rmdirsimple.pl line 17. current dir :/home/k/kh/prlfrg/dat/b file unlink :b/b.txt> at rmdirsimple.pl line 20. ok... at rmdirsimple.pl line 21. current dir :/home/k/kh/prlfrg/dat/b rmdir attempt :b ok... at rmdirsimple.pl line 17.
most depressing. i am sure that it's because the process is sitting in the directory it is attempting to delete. but if this *is* the case, how did rmtree1 from the cookbook ever... get into the cookbook! and does anyone know how the above problem might be solved within the confines of activestate perl?current dir :C:/cygwin/home/k/kh/prlfrg/dat/a file unlink :a/a.txt> at rmdirsimple.pl line 20. ok... at rmdirsimple.pl line 21. current dir :C:/cygwin/home/k/kh/prlfrg/dat/a rmdir attempt :a cannot rmdir a: Permission denied at rmdirsimple.pl line 17. current dir :C:/cygwin/home/k/kh/prlfrg/dat/b file unlink :b/b.txt> at rmdirsimple.pl line 20. ok... at rmdirsimple.pl line 21. current dir :C:/cygwin/home/k/kh/prlfrg/dat/b rmdir attempt :b cannot rmdir b: Permission denied at rmdirsimple.pl line 17.
|
|---|