use strict; use File::DosGlob 'glob'; my @files_to_check = ( 'file_a.txt', 'file_b.txt' ); FILE_IN_ALPHA_ORDER: foreach my $template_file ( sort @files_to_check ) { # The next three lines are for peeking at $template_file warn "ftf2: '$template_file'\n"; my $template_file_t2 = qq{"$template_file"}; warn "ftf2a: '$template_file_t2'\n"; unless ( -f ( File::DosGlob::glob qq{"$template_file"} ) ) { warn "8251b: File check, cannot access '$template_file', $!\n\n"; next FILE_IN_ALPHA_ORDER; } warn "ftf2b: '$template_file' is okay.\n\n"; } warn "\n"; FILE_IN_REVERSE_ORDER: foreach my $template_file ( reverse sort @files_to_check ) { # The next three lines are for peeking at $template_file warn "ftf3: '$template_file'\n"; my $template_file_t2 = qq{"$template_file"}; warn "ftf3a: '$template_file_t2'\n"; unless ( -f ( File::DosGlob::glob qq{"$template_file"} ) ) { warn "8251b: File check, cannot access '$template_file', $!\n\n"; next FILE_IN_REVERSE_ORDER; } warn "ftf2b: '$template_file' is okay.\n\n"; } __END__ Results look like: ftf2: 'file_a.txt' ftf2a: '"file_a.txt"' ftf2b: 'file_a.txt' is okay. ftf2: 'file_b.txt' ftf2a: '"file_b.txt"' 8251b: File check, cannot access 'file_b.txt', No such file or directory ftf3: 'file_b.txt' ftf3a: '"file_b.txt"' ftf2b: 'file_b.txt' is okay. ftf3: 'file_a.txt' ftf3a: '"file_a.txt"' 8251b: File check, cannot access 'file_a.txt', No such file or directory