Even on Windows the forward slash in filepaths works. That saves you a lot of escaping.
use Modern::Perl;
my $dirname = 'c:/data/eps';
opendir( DIR, $dirname );
my @files = readdir(DIR);
foreach my $file (@files) {
my $file_path = "$dirname/$file";
say "File path: $file_path";
}
closedir DIR;
Output
File path: c:/data/eps/.
File path: c:/data/eps/..
File path: c:/data/eps/agrafort.jpg
File path: c:/data/eps/alazif
File path: c:/data/eps/ARF.jpg
File path: c:/data/eps/ARF.png
...
For anything more complicated than a simple list of all files in a directory,
File::Find::Rule is something to think about (and it gives you the full file path).
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
My blog:
Imperial Deltronics