PerlIO::dir - Reads directories
open my $dirh, '<:dir', '.'; binmode $dirh, ':encoding(cp932)'; # OK my @dirs = <$dirh>; # added "\n" at the end of the name chomp @dirs; # if necessary
PerlIO::dir provides an interface to directory reading functions, opendir(), readdir(), rewinddir and closedir().
PerlIO::dir
opendir()
readdir()
rewinddir
closedir()
However, there is an important difference between :dir and Perl's readdir(). This layer appends a newline code, \n, to the end of the name, because readline() requires input separators. Call chomp() if necessary.
:dir
\n
readline()
chomp()
You can use seek($dirh, 0, 0) for rewinddir().
seek($dirh, 0, 0)
rewinddir()
"opendir" in perlfunc, "readdir" in perlfunc, "rewinddir" in perlfunc, "closedir" in perlfunc.
PerlIO::Util.
Goro Fuji (藤 吾郎) <gfuji (at) cpan.org>
Copyright (c) 2008, Goro Fuji <gfuji (at) cpan.org>. Some rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install PerlIO::Util, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PerlIO::Util
CPAN shell
perl -MCPAN -e shell install PerlIO::Util
For more information on module installation, please visit the detailed CPAN module installation guide.