in reply to Re^7: search a large text file
in thread search a large text file
Results:my $file_in_en=shift; my $hash_en=to_hash($file_in_en); print "@{$hash_en{'despite'}}";
expected result:17 18 18 18 18 18 18 18 18 18 18 18
When I try to use a normal hash in this way I get a correct result:18
my $file_in_en=shift; my %hash_en=to_hash($file_in_en); print "@{$hash_en{'despite'}}"; sub to_hash { my %hash; my $file = shift; open(FILE, "<$file"); foreach $l (<FILE>) { my ($ngram,$line) = split /\t/, $l; push(@{ $hash{$ngram} }, $line); } close FILE; return %hash; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^9: search a large text file
by jethro (Monsignor) on Feb 10, 2011 at 10:45 UTC | |
by perl_lover_always (Acolyte) on Feb 10, 2011 at 13:47 UTC | |
by jethro (Monsignor) on Feb 10, 2011 at 15:37 UTC |