{
    "mode": "perldoc",
    "parameter": "DirHandle",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/DirHandle/json",
    "generated": "2026-06-15T11:19:27Z",
    "synopsis": "# recommended approach since Perl 5.6: do not use DirHandle\nif (opendir my $d, '.') {\nwhile (readdir $d) { something($); }\nrewind $d;\nwhile (readdir $d) { somethingelse($); }\n}\n# how you would use this module if you were going to\nuse DirHandle;\nif (my $d = DirHandle->new(\".\")) {\nwhile (defined($ = $d->read)) { something($); }\n$d->rewind;\nwhile (defined($ = $d->read)) { somethingelse($); }\n}",
    "sections": {
        "NAME": {
            "content": "DirHandle - (obsolete) supply object methods for directory handles\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "# recommended approach since Perl 5.6: do not use DirHandle\nif (opendir my $d, '.') {\nwhile (readdir $d) { something($); }\nrewind $d;\nwhile (readdir $d) { somethingelse($); }\n}\n\n# how you would use this module if you were going to\nuse DirHandle;\nif (my $d = DirHandle->new(\".\")) {\nwhile (defined($ = $d->read)) { something($); }\n$d->rewind;\nwhile (defined($ = $d->read)) { somethingelse($); }\n}\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "There is no reason to use this module nowadays.\n\nThe \"DirHandle\" method provide an alternative interface to the opendir(), closedir(), readdir(),\nand rewinddir() functions.\n\nUp to Perl 5.5, opendir() could not autovivify a directory handle from \"undef\", so using a\nlexical handle required using a function from Symbol to create an anonymous glob, which took a\nseparate step. \"DirHandle\" encapsulates this, which allowed cleaner code than opendir(). Since\nPerl 5.6, opendir() alone has been all you need for lexical handles.\n",
            "subsections": []
        }
    },
    "summary": "DirHandle - (obsolete) supply object methods for directory handles",
    "flags": [],
    "examples": [],
    "see_also": []
}