I've never been a fan of readdir, when simpler list functions will do the same thing for you. If you had a single directory with 100_000 filenames in it, I might be inclined to believe that the readdir approach would be more appropriate.
my $path = '/home/username/me/cgi-bin/files';
my @files = grep { -f and m/\.(exe|wav|swf)$/i }
glob("$path/*");