Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

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]
[marto]: which part don't you know how to do?
[marto]: oh
[Corion]: arunks: Maybe How do I make password prompts not echo back the user?? Or simply read it from STDIN.
[Corion]: arunks: Please do not ask us to write your program. You have to write your program yourself.

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (11)
As of 2017-01-20 14:25 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (174 votes). Check out past polls.