Perl 5 version 20.3 documentation

DirHandle

NAME

DirHandle - supply object methods for directory handles

SYNOPSIS

  1. use DirHandle;
  2. $d = DirHandle->new(".");
  3. if (defined $d) {
  4. while (defined($_ = $d->read)) { something($_); }
  5. $d->rewind;
  6. while (defined($_ = $d->read)) { something_else($_); }
  7. undef $d;
  8. }

DESCRIPTION

The DirHandle method provide an alternative interface to the opendir(), closedir(), readdir(), and rewinddir() functions.

The only objective benefit to using DirHandle is that it avoids namespace pollution by creating globs to hold directory handles.