Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re^2: Unable to read files from a directory

by bluto (Curate)
on May 14, 2009 at 15:07 UTC ( #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 like a charm...what the heck??!!!

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2016-10-26 23:15 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (350 votes). Check out past polls.