use strict; use warnings; my @file = qw(foo bar baz); for (@file) { open FH, "path/to/file/$_"; print while ; close FH; }