my @files = qw(bla.txt blubb.dat test.txt); for my $file(@files){ open(my $fh,'<',$file) or die $!; # mach was close $fh; }