Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: Unable to read files from a directory

by bluto (Curate)
on May 14, 2009 at 15:07 UTC ( [id://764099]=note: print w/replies, xml ) Need Help??


in reply to Re: Unable to read files from a directory
in thread Unable to read files from a directory

Next, change the "readdir" line to be like this:

@files = grep { -f } readdir DIR;

That will assure that the @files array contains only things that can properly be opened as files (i.e. things that are not other directories).

This will only work when the current directory happens to be the same as $path. readdir returns bare file names, so in the general case a file should be turned into a full path before sending it to -f. I've been bitten by this more times than I can count (e.g. it works "fine" during testing, but then fails under normal use).

Replies are listed 'Best First'.
Re^3: Unable to read files from a directory
by antidote1316 (Initiate) on May 14, 2009 at 17:38 UTC
    keeps biting still...nothing seemed to work on Windows...ported it to Linux...works like a charm...what the heck??!!!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://764099]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (7)
As of 2024-03-29 08:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found