in reply to Re: deleting windows subdirectories
in thread deleting windows subdirectories

That's not going to work and you're not going to have any idea why, because you're not attempting to check whether the system call (unlink) fails, and if so, for what reason ($!).

The code will try to delete a directory first, before attempting to delete the files within said directory. At the very least, it should do a depth first search. Even so, be careful about the . and .. entries.

Use the rmtree approach instead.


print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u'

Replies are listed 'Best First'.
Re: Re:x2 deleting windows subdirectories
by Steve_p (Priest) on Jun 04, 2002 at 20:34 UTC
    The unlink on the directory will only be tried if it read
    unless(-f){ unlink $File::Find::name; }
    The if(-f) prevents you from deleting anything but files. That means the directories are left alone. True, I should have a die, but it does work, and I use similar code regularly.