That kevinadc and Sinan Unur use, but does not mention, that readdir() returns a list of all the entries in the directory when called in a list context. Then you can use any list operator. This is why you can use:
my @files = grep (/abc/ && !/\.xh$/), readdir MYDIR;
So:
readdir MYDIR
returns a list of all files in MYDIR.
and
grep (/abc/ && !/\.xh$/)
returns all items returned by readdir MYDIR that match the criteria there.
Nathan fellman
source share