my @file_to_process = glob('*.xlsx *.pdf'); die "No file to process!" unless $file_to_process[0]; print scalar @file_to_process, " files found\n"; foreach my $file (@file_to_process){ # your processing here ...