http://www.perlmonks.org?node_id=54817


in reply to Bad file descriptor

You'll not be wanting open rather opendir:

opendir DIRHANDLE,EXPR

Opens a directory named EXPR for processing by readdir, telldir, seekdir, rewinddir, and closedir. Returns true if successful. DIRHANDLEs have their own namespace separate from FILEHANDLEs.