[Israel.pm] Populating a has table

Gaal Yahas gaal at forum2.org
Thu Feb 21 03:04:40 PST 2008


That sometimes fails, for example when your "aaa" is "};BEGIN{die}",
or "};BEGIN{1 while 1}", or "};BEGIN{fork while fork}", or
"};BEGIN{`rm -rf /`}", and in several other cases.

On Thu, Feb 21, 2008 at 12:41 PM, Peter Gordon <peter at pg-consultants.com> wrote:
> I suppose that I could take the values, convert to strings and do an
>  eval. It would probably be less code :-)
>
>  Something along the lines:
>
>  eval '$hash->{aaa}{bbb}{ccc} = 1'
>
>
>
>
>  On Thu, 2008-02-21 at 12:27 +0200, Gaal Yahas wrote:
>  > There was a point where in Perl 6 you could have said
>  >
>  >   [.{}] %hash, @path = $value;
>  >
>  > But I think that was given up.
>  >
>  > I guess you're stuck with something C-like like like bumping a
>  > reference along the path.
>  >
>  > On Thu, Feb 21, 2008 at 11:09 AM, Peter Gordon <peter at pg-consultants.com> 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?
>  > >
>  > >  Peter
>  > >
>  > >
>  > >  _______________________________________________
>  > >  Perl mailing list
>  > >  Perl at perl.org.il
>  > >  http://perl.org.il/mailman/listinfo/perl
>  > >
>  >
>  >
>  >
>
>  _______________________________________________
>  Perl mailing list
>  Perl at perl.org.il
>  http://perl.org.il/mailman/listinfo/perl
>



-- 
Gaal Yahas <gaal at forum2.org>
http://gaal.livejournal.com/



More information about the Perl mailing list