use strict; use File::DosGlob qw(bsd_glob); my @files = glob 'ABi1*'; foreach my $file (@files) { open my $fh, '<', $file or die "Couldn't read '$file': $!"; while (<$fh>) { ... do your function }; # EOF, do end of file cleanup };