my @files = ("foo.txt"); #### aaa bbb ccc 000 111 222 #### ( "111" => ["sth"], "bbb" => ["sth"] ) #### 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; } #### ( { "111" => ["sth"], # data from foo.txt "bbb" => ["sth"] }, { ... } # data from bar.txt )