unless ($files[0]){ print "\nSorry, no xml file(s) in script folder\n\nScript Terminated...\n\n"; } else{ ... # a gazillion rows }