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

Re: Reading all files in a directory with one filehandle

by tinita (Parson)
on Apr 03, 2013 at 09:40 UTC ( [id://1026808]=note: print w/replies, xml ) Need Help??


in reply to Reading all files in a directory with one filehandle

The array @files only contains the filenames without the full path. Prepend the path of the directory to the filename. And please use some more modern code for open:
open my $fh, "<", "/tmp/files/$file" or die $!;

The code to ignore . and .. also looks strange to me. I usually do
my @files = grep { not m/^\.\.?$/ } readdir $dh;

Replies are listed 'Best First'.
Re^2: Reading all files in a directory with one filehandle
by rahulruns (Scribe) on Apr 03, 2013 at 09:43 UTC

    Figured out the problem. I am working on the code this is just one sample part and need modification. True we should use more modern code

      See also readdir documentation for further explanation and examples.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-04-25 14:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found