in reply to Array values into hash

Please be careful with some of the solutions posted here. While in principle they may work most suffer from one bad practice or another (mostly the fact that they are slurping in potentially huge files for no good reason).

Here is a relatively "textbook" solution.

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; }
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)

--- demerphq
my friends call me, usually because I'm late....