Is there a function in Perl that lists all the files and directories in a directory?
I remember that Java has the File.list() to do this? Is there a comparable method in Perl?
Is there a function in Perl that lists all the files and directories in
Share
If you want to get content of given directory, and only it (i.e. no subdirectories), the best way is to use opendir/readdir/closedir:
You can also use:
But in my opinion it is not as good – mostly because glob is quite complex thing (can filter results automatically) and using it to get all elements of directory seems as a too simple task.
On the other hand, if you need to get content from all of the directories and subdirectories, there is basically one standard solution: