#create hash files from ngram statistics my %hash_en; to_hash( \%hash_en, $file_in_en ); my %hash_es; to_hash( \%hash_es, $file_in_es ); ... sub to_hash { my( $href, $file ) = @_; open(FILE, "<$file"); foreach my $l () { my( $ngram, $line ) = split /\t/, $l; push @{ $href->{ $ngram } }, $line; } close FILE; }