[Israel.pm] Populating a has table

Shlomi Fish shlomif at iglu.org.il
Thu Feb 21 03:09:23 PST 2008


On Thursday 21 February 2008, Peter Gordon wrote:
> Suppose I have the following raw data
> aaa bbb ccc 1
> ddd eee 2
> aaa fff ddd hhh 3
> ....
>
>
> I want to populate a hash thusly:
> $hash->{aaa}{bbb}{ccc} = 1
> $hash->{ddd}{eee} = 2
> $hash->{aaa}{fff}{ddd}{hhh} = 3
> ....
>
> What is the best way for populating the hash from the raw data, given
> that the data could go to any depth?
>

I don't know of a better way than using a loop or recursion. But there may be 
CPAN modules for doing that.

Regards,

	Shlomi Fish

---------------------------------------------------------------------
Shlomi Fish      shlomif at iglu.org.il
Homepage:        http://www.shlomifish.org/

I'm not an actor - I just play one on T.V.



More information about the Perl mailing list