my @files = qw/file1 file2 file3/; foreach my $file (@files) { open( INFILE, '<', './lib/Foo/Foo1/Foo2/' . $file . ".txt" ) or die "$0 : ERROR : could not open file '" . $file . ".txt' : $!\n"; [CODE HERE] }