opendir(DIR, $dir); @files = grep { /(.jpg|.JPG)$/ } readdir(DIR); closedir(DIR);