Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

opendir

Opens a directory for reading via a directory handle.

Associates a directory handle with the named directory. The handle can then be used with readdir, rewinddir, seekdir, telldir, and closedir. All directory entries (including . and ..) are loaded eagerly into a Vec at open time.

The directory handle variable receives a numeric ID stored in the global DIRHANDLE_TABLE. Both lexical (my $dh) and bareword (DH) forms are supported.

Returns 1 on success, undef on failure.

Synopsis

opendir(my $dh, $dir) or die "Cannot open $dir: $!";
opendir(DH, "/tmp");

See Also

readdir, closedir, rewinddir, File::Find