Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1007998]
help
Chatterbox?
[Discipulus]: Ah! if so you must play with him not with us ;=)
[vrk]: Hope he gets better soon.
[Discipulus]: hdb sorry i profit; is known that a prime number is never a figurate one nor the sumattion of two adjacent figurates of the same order? like 3th triangular+3th tetrahedric
[Discipulus]: if known where i can read about the matter?
[choroba]: he's not really sick, we just got nobody to look after him today
[Discipulus]: create an account for him; we are funny baby sitters ;=) come here child, want to listen the typeglob tale?
[vrk]: choroba Oh, that's good.
[vrk]: Discipulus I don't know much about prime numbers, but wouldn't that kind of an answer be in a graduate-level number theory book?
[Discipulus]: my 8 yo daughter has two weeks of sleep disturbs.. we are gonna be crazy..

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (9)
As of 2017-04-27 07:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (501 votes). Check out past polls.