go ahead... be a heretic | |
PerlMonks |
Re: Extract information from several files in directoryby wazat (Monk) |
on Nov 29, 2020 at 18:32 UTC ( [id://11124371]=note: print w/replies, xml ) | Need Help?? |
One thing to be aware of is that readdir() returns file names without the directory part. If using readdir() you will need to prepend the file names with the directory part of the file path in order to open it for reading. You could just build the path yourself, which is not necessarily portable.
or you could use File::Spec->catfile() for portability
This is an old fashioned approach. If you use glob() it will return file paths. Then again for portability code>File::Spec->catfile()</code> could be used to build the argument to glob(). As others have pointed out, using Path::Tiny simple. It is a more modern approach. For example
In Section
Seekers of Perl Wisdom
|
|