in reply to cant open files from a directory
parv++
All is well
readdir(D) gives only the file names, if you included the $! in the file open function it could have given you the "oops No such file or directory" error message, in the file open function give the absolute path to open the file.
Here is the code I checked.
my $handle=$ARGV[0]; opendir(D,$handle) or die "cannot open $!"; my @files=readdir(D); print "@files\n"; foreach my $file(@files) { open (MYFILE,"$handle/$file") or die "oops $!"; while(<MYFILE>) { print $_; } } closedir(D);
All is well
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: cant open files from a directory
by x-lours (Sexton) on Jan 31, 2014 at 15:15 UTC | |
by Anonymous Monk on Feb 01, 2014 at 05:31 UTC |
In Section
Seekers of Perl Wisdom