in reply to Re^4: tying a hash from a big dictionary
in thread tying a hash from a big dictionary
The addition of the following 3 lines should tell you with sufficient accuracy after a single run:
sub read_dict{ local $| = 1; ##! my $file = shift; my %dict; open( my $fh, "<:encoding(utf5)", $file ); my $c = 0; ##! while( <FILE> ) { printf "\r%d\t", $c unless ++$c % 1000; ##! chomp; ## no need to chomp twice my ($p1, $p2) = split /\t/; push( @{ $dict{ $p1 } }, $p2 ); } close $fh; return \%dict; ## main space saving change; return a ref to the ha +sh }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: tying a hash from a big dictionary
by Anonymous Monk on Oct 31, 2011 at 14:54 UTC | |
by BrowserUk (Patriarch) on Oct 31, 2011 at 15:18 UTC |