use DirHandle; my $d = new DirHandle "."; # open the current directory if (defined $d) { while (defined($_ = $d->read)) { something($_); } $d->rewind; while (defined($_ = $d->read)) { something_else($_); } }
DirHandle provides an alternative interface to Perl's opendir , closedir , readdir , and rewinddir functions.
The only objective benefit to using DirHandle is that it avoids name-space pollution by creating anonymous globs to hold directory handles. Well, and it also closes the DirHandle automatically when the last reference goes out of scope. But since most people only keep a directory handle open long enough to slurp in all the filenames, this is of dubious value. But hey, it's object-oriented.
7.2.10 diagnostics - Force Verbose Warning Diagnostics | 7.2.12 DynaLoader - Automatic Dynamic Loading of Perl Modules |