in reply to A couple of problems....

How about something like this? do the logging then die

if (!rmdir $_) { open(LOG, ">>$logfile") or warn "discarding logfile output \n"; print LOG "Directory: $_ - had a problem deleting.\n"; close (LOG) or warn "Can't close: $!"; die "could not rmdir $_\n"; }