[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).

  --Yuval

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;
>}
>
>Murray
>-------------------
>Prager, Mark wrote:
>
>  
>
>>I am trying to read in input file into a hash -
>>i.e 
>>File:
>>3 a
>>4 ssd
>>would go into a hash indexed by the first column.
>>    
>>
>
>_______________________________________________
>Perl mailing list
>Perl at perl.org.il
>http://www.perl.org.il/mailman/listinfo/perl
>
>YAPC::Israel::2004
>http://www.perl.org.il/YAPC/2004/
>
>
>  
>




More information about the Perl mailing list