my $path = '/home/username/me/cgi-bin/files'; my @files = grep { -f and m/\.(exe|wav|swf)$/i } glob("$path/*");