my @files = glob '*.cold'; # you are using strict, no? if (scalar(@files) == 0) { print "Nothing matched\n"; } else { foreach (@files) { if (/^cold/) { print CBDOWNLOAD "Cold Backup file exists for DULS for $FileName.\n" } else { system ('awtrap -h RLGH -f DULS "DULSVASG001: Unable to download the +file."'); } } }