in reply to Bad file descriptor

That should be:
opendir(DIR, ".") or die "Can't open the current directory: $!\n";
instead of just open()