in reply to How to list all the things in a directory?

File::Slurp::read_dir from CPAN provides the same functionality as the opendir/readdir built-in combination. It also innately checks if the opendir failed.
use File::Slurp qw(read_dir); my @things = read_dir($dir, keep_dot_dot => 1);
To assuage your platform-dependence fears, it seems to have good coverage according to the CPAN Testers "Perl/Platform Version Matrix".

Replies are listed 'Best First'.
Re^2: How to list all the things in a directory?
by DrHyde (Prior) on May 05, 2010 at 10:30 UTC

    That matrix only covers platforms that CPAN-testers have used. CPAN-testers have pretty good coverage on Unix-a-likes and Windows, but there's no-one testing regularly with VMS, RISC OS or Amiga. And those are the sort of platforms that you'd expect to have the most portability problems.

    I have anecdotal evidence that most modules don't pass their tests on VMS, and that VMS users are used to patching them locally. Unfortunately, I don't think any of them have got round to patching the CPAN-testing tools and submitting patches back to the maintainers. Anyone with a home VAX who can dedicate some time to that? Maybe you could apply for a TPF grant!