Help language development. Donate to The Perl Foundation

DirHandle zef:lizmat last updated on 2021-09-09
[![Actions Status](](


Raku port of Perl's DirHandle module


    use DirHandle;
    with".") -> $d {
        while $ -> $entry { something($entry) }
        while $ { something_else($_) }


This module tries to mimic the behaviour of Perl's `DirHandle` module as closely as possible in the Raku Programming Language.

The DirHandle object provides an alternative interface to the `opendir`, `closedir`, `readdir`, `telldir`, `seekdir` and `rewinddir` functions.

The only objective benefit to using DirHandle is that it avoids namespace pollution.


Handling void context

Since Raku does not have a concept like void context, one needs to specify `Mu` as the only positional parameter with `read` to mimic the behaviour of `` of Perl in void context.

Please note that due to optimizations in Raku from version `6.d` onwards, it is no longer possible to (always) assign to `$_` in the caller's scope. So this either locks your code into `6.c`, or you will need to change your code to do explicit assignment with the `read` method.

Extra methods

The Perl version of `DirHandle` for some mysterious reason does not contain methods for performing a `telldir` or a `seekdir`. The Raku version **does** contain equivalent methods `tell` and `seek`.


Elizabeth Mattijsen <[email protected]>

Source can be located at: . Comments and Pull Requests are welcome.


Copyright 2018, 2019, 2020, 2021 Elizabeth Mattijsen

Re-imagined from Perl as part of the CPAN Butterfly Plan.

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.