Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Answer: How do I read files from a folder and place them into a list?

by ctilmes (Priest)
on Apr 22, 2003 at 15:38 UTC ( #252291=categorized answer: print w/replies, xml ) Need Help??

Q&A > arrays > How do I read files from a folder and place them into a list? - Answer contributed by ctilmes

File::Slurp offers a shortcut for the opendir/readdir/closedir idiom:
use File::Slurp; my $dir = '.'; # or whatever my @files = sort grep { -f "$dir/$_" } read_dir($dir);
Note that File::Slurp::read_dir automatically skips '.' and '..'.

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (9)
As of 2017-02-27 21:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (393 votes). Check out past polls.