in reply to Put "ls" in array
You can get the output of system commands like ls into an array with this:
my @array= `ls`;
Note that these are backticks, not the normal quotes. Also you might use chomp() afterwards on the array to remove the line endings
In your case it would also be possible to use opendir()/readdir() to read a directory like a file
The order of the files on disk will look pretty random to you by the way (at least if you have deleted and created lots of files in this directory already, otherwise they might be in order of creation). If you want to sort them, perl has a sort() function as well
In Section
Seekers of Perl Wisdom