ЭЛЕКТРОННАЯ БИБЛИОТЕКА КОАПП
Сборники Художественной, Технической, Справочной, Английской, Нормативной, Исторической, и др. литературы.



7.2.11 DirHandle - Supply Object Methods for Directory Handles

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.


Previous: 7.2.10 diagnostics - Force Verbose Warning DiagnosticsProgramming PerlNext: 7.2.12 DynaLoader - Automatic Dynamic Loading of Perl Modules
7.2.10 diagnostics - Force Verbose Warning DiagnosticsBook Index7.2.12 DynaLoader - Automatic Dynamic Loading of Perl Modules