And to add a little variety, you can also do things like this:
opendir(DIR, $path) || die qq([ERROR] Cannot opendir "$path" - $!\n); my(@txt) = grep(m{\.txt$}, readdir DIR); rewinddir DIR; my(@lt6) = grep(m{\.lt6$}, readdir DIR); rewinddir DIR; my(@dirs) = grep(-d "$path/$_", readdir DIR); closedir DIR;
And so on.
source share