Chj::xopendir
use Chj::xopendir; { my $dir = xopendir "/foo"; while (defined(my $item = $dir->read)) { print $item; } } # $dir is closed automatically (issuing a warning on error)
Something like IO::Dir, but more lightweight (IO::Dir takes about 0.3 seconds to load on my laptop, whereas this module takes less than 30ms), and with functions/methods that throw (currently untyped) exceptions on error.
Open the given dir or croak on errors. Returns an anonymous symbol blessed into Chj::xopendir::dir, which can be used both as object or filehandle (more correctly: anonymous glob) (? always? Perl is a bit complicated when handling filehandles in indirect object notation).
Try to open given directory path, if successful return the filehandle, otherwise return () and leave $! set.
Same as perhaps_opendir but throw exception on all errors except for ENOENT.
Same as xopendir, but in object oriented notation (overridable).
Read one dir entry in scalar context, all entries in list context. xread croaks if it detects an error, though it's quite unsure if that really works (see also module source).
Same as read/xread but discard "." and ".." entries.
Close dirhandle and croak on error. (If not called before descruction of the object, the filehandle is closed anyway, but only a warning is issued upon errors in that case.)
Chj::xopen
This is alpha software! Read the status section in the package README or on the website.
To install FunctionalPerl, copy and paste the appropriate command in to your terminal.
cpanm
cpanm FunctionalPerl
CPAN shell
perl -MCPAN -e shell install FunctionalPerl
For more information on module installation, please visit the detailed CPAN module installation guide.