The POSIX documents available to me and Stevens' APUE
say that the remove() function should be equivalent to
rmdir() if the given path is a directory. However I do
not have an original copy of POSIX.1-1990 (I think the
POSIX module is based on that version) to double-check
this.
Here is a proposal for a patch to achieve the described
behaviour with the POSIX module.
$ diff -urd perl-current/ext/POSIX/POSIX.pm /var/tmp/POSIX.pm
--- perl-current/ext/POSIX/POSIX.pm 2006-08-16 15:13:35.000000000 +0200
+++ /var/tmp/POSIX.pm 2006-11-22 17:23:04.000000000 +0100
@@ -421,7 +421,7 @@
sub remove {
usage "remove(filename)" if @_ != 1;
- CORE::unlink($_[0]);
+ (-d $_[0]) ? CORE::rmdir($_[0]) : CORE::unlink($_[0]);
}
sub rename {
Thread Next