Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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

by ctilmes (Vicar)
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?
marioroy Updated Re^3: RFC: Compiling Gtk+ stack on windows with strawberry perl. Also tested Gtk2 installation on Strawberry Perl v5.22.3.1. Installing Tk and Tk::Zinc works fine on Perl v5.22.3.1.

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2017-09-24 09:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (273 votes). Check out past polls.

    Notices?