Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

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

( #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? 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 '..'.

Comment on Answer: How do I read files from a folder and place them into a list?
Select or Download Code
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (11)
As of 2014-11-27 10:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (183 votes), past polls