my @files = qw( /path/to/file1 /path/to/file2 /path/to/file3 ); for my $file (@files){ open my $fd, '<', $file or die $!; while(my $line = <$fd>){ # do stuff with the next line } close $fd; }