use warnings; use strict; my @files = ("foo.txt", "bar.txt"); my @wow; foreach my $i (0..$#files) { open my $fh, "<", $files[$i]; while(<$fh>){ chomp; my @row = split /\t/; push @{$wow[$i]->{$row[1]}}, "sth"; } close $fh; }