1DirHandle(3pm)         Perl Programmers Reference Guide         DirHandle(3pm)
2
3
4

NAME

6       DirHandle - (obsolete) supply object methods for directory handles
7

SYNOPSIS

9           # recommended approach since Perl 5.6: do not use DirHandle
10           if (opendir my $d, '.') {
11               while (readdir $d) { something($_); }
12               rewind $d;
13               while (readdir $d) { something_else($_); }
14           }
15
16           # how you would use this module if you were going to
17           use DirHandle;
18           if (my $d = DirHandle->new(".")) {
19               while (defined($_ = $d->read)) { something($_); }
20               $d->rewind;
21               while (defined($_ = $d->read)) { something_else($_); }
22           }
23

DESCRIPTION

25       There is no reason to use this module nowadays.
26
27       The "DirHandle" method provide an alternative interface to the
28       opendir(), closedir(), readdir(), and rewinddir() functions.
29
30       Up to Perl 5.5, opendir() could not autovivify a directory handle from
31       "undef", so using a lexical handle required using a function from
32       Symbol to create an anonymous glob, which took a separate step.
33       "DirHandle" encapsulates this, which allowed cleaner code than
34       opendir().  Since Perl 5.6, opendir() alone has been all you need for
35       lexical handles.
36
37
38
39perl v5.34.0                      2021-10-18                    DirHandle(3pm)
Impressum