for my $nr (1..2) { for my $line (read_file('file'.$nr)) { my @cols = split(/\t/,$line); push @{$data[$nr - 1]->{shift(@cols)}},\@cols; } }