Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: How to get full path name in windows?

by CountZero (Bishop)
on Dec 09, 2012 at 18:52 UTC ( #1007998=note: print w/ replies, xml ) Need Help??


in reply to How to get full path name in windows?

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


Comment on Re: How to get full path name in windows?
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1007998]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2014-12-29 01:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (183 votes), past polls