$fileGlob = '/var/adm/messages.*'; my @file = glob $fileGlob; if(not @file) { # glob was wrong or there were no files } for (@file){ # do some things to check each file }