manpagez: man pages & more
man DirHandle(3)
Home | html | info | man
DirHandle(3pm)         Perl Programmers Reference Guide         DirHandle(3pm)


       DirHandle - (obsolete) supply object methods for directory handles


           # recommended approach since Perl 5.6: do not use DirHandle
           if (opendir my $d, '.') {
               while (readdir $d) { something($_); }
               rewind $d;
               while (readdir $d) { something_else($_); }

           # how you would use this module if you were going to
           use DirHandle;
           if (my $d = DirHandle->new(".")) {
               while (defined($_ = $d->read)) { something($_); }
               while (defined($_ = $d->read)) { something_else($_); }


       There is no reason to use this module nowadays.

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

       Up to Perl 5.5, opendir() could not autovivify a directory handle from
       "undef", so using a lexical handle required using a function from
       Symbol to create an anonymous glob, which took a separate step.
       "DirHandle" encapsulates this, which allowed cleaner code than
       opendir().  Since Perl 5.6, opendir() alone has been all you need for
       lexical handles.

perl v5.28.1                      2018-11-01                    DirHandle(3pm)

perl 5.28.1 - Generated Sat Jan 12 06:33:31 CST 2019
© 2000-2024
Individual documents may contain additional copyright information.