7.2.11 DirHandle - Supply Object Methods for Directory Handlesuse 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. |
|