my ($filename1, $filename2) = qw( adaykin1.txt adaykin2.txt ); my @string; for my $fn ($filename1, $filename2) { # iterate over given filenames open my $fh, '<', $fn or die "$fn - $!"; # open each file local $/; push @string, <$fh> # read it into one string } # print $string[0]; # first file as one big string print $string[1]; # second file as one big string ...