opendir (DIR, '/html/downloads/'); @files = grep /-output.txt/, readdir (DIR); closedir(DIR); foreach (@files) { unlink ("/html/downloads/$_"); }