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.