IndirectX has asked for the wisdom of the Perl Monks concerning the following question:

I'm wondering how I can list all the files in a given directory, and store the names of them individually in an array. Can someone offer some code in order to do this? Or even the functions that accomplish it with what they return would work.

thanks


- IndirectX: The next generation of graphics APIs. -

Replies are listed 'Best First'.
Re: Listing a directory
by chromatic (Archbishop) on Feb 24, 2002 at 21:48 UTC
Re: Listing a directory
by beebware (Pilgrim) on Feb 24, 2002 at 22:06 UTC
    You mean something like:
    $dirtoget="/home/yourname/www/images/"; opendir(IMD, $dirtoget) || die("Cannot open directory"); @thefiles= readdir(IMD); closedir(IMD);
    A quick search on Google for opendir contents of directory produced this page which may of of use to you. But it really is that simple!