in reply to Array values into hash
Here is a relatively "textbook" solution.
By using the while you only have one line in memory at once. So even though the hash grows you dont have multiple copys of the file in memory at once (even if they are in different forms. For instance, the map solution posted here actually holds the data in ram 3 times at one critical moment. Once in the input list, once as a list of elements to go into the hash and once in the hash itself)my %hash; open my $fh,$file or die "$file : $!"; while (<$fh>) { my ($key,$value) = split /\|/; warn "$_ seems not to be formatted correctly" unless defined($key) and length($key); $hash{$key}=$value; }
--- demerphq
my friends call me, usually because I'm late....
|
|---|