in reply to Reading a directory into an array using <>
Also, if you use diagnostics, you should get a little more help on that message:readline() on unopened filehandle at ...
Well, those might not be the most helpful messages to you, but at least they give you an idea that something is amiss. To avoid the voodoo of <>, use glob:readline() on unopened filehandle at ... (#1) (W unopened) An I/O operation was attempted on a filehandle that w +as never initialized. You need to do an open(), a sysopen(), or a so +cket() call, or call a constructor from the FileHandle package.
See also:use warnings; use strict; my $path = '/var/log/*'; my @files = grep { -f } glob $path;
|
|---|