my @combinedData; my @currentFile; my @filesList = <*>; foreach my $file (@filesList) { open(F, "file.txt") or die("Unable to open file"); @currentFile = ; # HOW TO COMBINE IT INTO @combinedData ? # if I do it thru a reference the content # will change in the next loop when I modify @currentFile # again ... }