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 ( #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).


Comment on Re^2: Unable to read files from a directory
Download Code
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
Node Status?
node history
Node Type: note [id://764099]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2014-12-21 23:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (109 votes), past polls