At 12:42 PM 08-05-01 -0400, Carl Rogers wrote:
>Sorry if this is a dumb question.. (I know, there is no such thing as a 
>dumb question- only questions asked by dumb people:)
>
>I used the opendir() function in my Perl script to point to a folder with 
>200+ text files for the purpose of extracting data from each file.
>
>If I run the script with opendir/readdir pointing to a directory on a 
>shared drive, I'll get to a point where Perl tells me "Can't open file- no 
>such file or directory"

This may be a dumb answer, but, here goes:

Are you adding the path to the file name?
opendir() gives you plain file names, you have to add the path to them to 
open them.

   my $sPath = ...any path
   opendir(DIR, $sPath);
   # Get all files in folder
   my @asFiles = grep { -f "$sPath$_" } readdir(DIR);
   closedir DIR;
   foreach my $sFile (@asFiles)
     {
     my $sPathFileName = "$sPath\\$sFile";
     open INFILE, "<$sPathFileName";
     ...
     close(INFILE);
     }

Hope that helps.

Joe

Reply via email to