Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hello Perl Monks
I wrote a code to get the absolute paths of the files in a directory,but I get the path showing the files as present in current directory.
Eg: Here, I'm using the directory Cluster1 on the desktop with files doc.txt,volt.txt and holiday.txt. The absolute path should be C:\\Users\\Me\\Desktop\\Cluster1\\doc.txt. But, I get the output as D:\Prog\Perls\doc.txt(D:\Prog\Perls is the location where I execute my code).
Can you suggest a way to get the absolute path of the file from its original location.(I would also like the path to have 2 escape characters(\\) as a single one doesn't work while accessing a file.)$dirname="C:\\Users\\Me\\Desktop\\Cluster1"; opendir(DIR, $dirname); @FILES= readdir(DIR); foreach $FILE (@FILES){ $fil_path = File::Spec->rel2abs($FILE); print "File path:", $fil_path; } closedir DIR;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to get full path name in windows?
by CountZero (Bishop) on Dec 09, 2012 at 18:52 UTC | |
|
Re: How to get full path name in windows?
by ww (Archbishop) on Dec 09, 2012 at 18:14 UTC | |
|
Re: How to get full path name in windows?
by bart (Canon) on Dec 10, 2012 at 12:47 UTC | |
|
Re: How to get full path name in windows?
by Tommy (Chaplain) on Dec 09, 2012 at 22:30 UTC | |
|
Re: How to get full path name in windows?
by Khen1950fx (Canon) on Dec 09, 2012 at 22:48 UTC | |
|
Re: How to get full path name in windows?
by 2teez (Vicar) on Dec 10, 2012 at 03:59 UTC |