in reply to Deleting a Directory

It's nothing to do with your problem, but this is a bad idea:

rmdir ( "$_" ) or die ("Could not remove $_");

See What's wrong with always quoting "$vars"? for more details.

--
<http://dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg