Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
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 imbibing at the Monastery: (7)
As of 2016-12-10 14:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (163 votes). Check out past polls.