--- name: opendir status: documented runtime: pp source: src/runtime/pp/directory.rs --- ```{index} single: opendir; Perl built-in (pp runtime) ``` # opendir ## Synopsis ```perl opendir(my $dh, $dir) or die "Cannot open $dir: $!"; opendir(DH, "/tmp"); ``` ## Description 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. ## See also readdir, closedir, rewinddir, File::Find