[Israel.pm] re: Another newbie question - Hashes

Yuval Yaari yuval at windax.com
Thu Feb 5 01:17:04 PST 2004

I use a similar function to what I posted to parse configuration.
The problem with yours would be that usually people prefer to use 
several spaces to tell between the key and value.
Just change / / to /\s+/ :)

Remember, TIM-TODAY (I think that's how Tom Christiansen said TMTOWTDI 
is pronounced, but I'm not sure).


Murray Gingold wrote:

>I know a couple of good answers were posted to this, but I thought I'd add
>the solution I usually use, somewhat similar to the method Gabor posted
>from his notes:
>my %hash ;
>if (open INFILE, "<file") {
>    %hash = (map {chomp; split / /, $_, 2} <INFILE>);
>    close INFILE;
>Prager, Mark wrote:
>>I am trying to read in input file into a hash -
>>3 a
>>4 ssd
>>would go into a hash indexed by the first column.
>Perl mailing list
>Perl at perl.org.il

More information about the Perl mailing list