in reply to How do you list all files under a directory?

This glob stuff can get hairy as there are multiple versions of it. I've had some big troubles in the past with this in the Windows environment. Adding a grep to process the list from readdir is portable and is just a few more characters to your standard "formula".

Technically a directory is a file, but -f means the subset of files that aren't directories (which excludes '.' and '..'). Be sure to use a full path name in the grep otherwise you will be testing against files in the directory that the program is executing in, which is probably not what you want! When I do want that, I set $dir = "." and use the same formula.

my $dir="/path/to/dir"; opendir(DIR, $dir) or die "can't open $dir: $!"; my @files = grep {-f "$dir/$_"} readdir DIR; closedir DIR;
Updated: added single quotes to make '.' and '..' more clear in some fonts.