Re: Unknown level of hash

2005-03-29 Thread Alexandre Jousset
Yitzchak Scott-Thoennes wrote: To set it, you need to just do the same thing except that at each step instead of keeping the hash element, you keep a reference to it: $entryref = \$hash; $entryref = \$$entryref-{$_} for @a; $$entryref = 1; Note that this will create hashrefs at any undefined

Re: Unknown level of hash

2005-03-29 Thread Yitzchak Scott-Thoennes
On Tue, Mar 29, 2005 at 11:45:01AM +0200, Alexandre Jousset wrote: Yitzchak Scott-Thoennes wrote: To set it, you need to just do the same thing except that at each step instead of keeping the hash element, you keep a reference to it: $entryref = \$hash; $entryref = \$$entryref-{$_} for @a;

Re: Unknown level of hash

2005-03-29 Thread Alexandre Jousset
Yitzchak Scott-Thoennes wrote: I'm sorry but that doesn't work as is on my system: Not a HASH reference at x.pl line 9.. Works for me. Can you show the actual code you are trying? In fact I made a mistake. Sorry again, you're right ! :-) -- \^/ -/ O

Re: Unknown level of hash

2005-03-29 Thread Alexandre Jousset
wrote: [snip code...] gives: $VAR1 = { 'E1' = { 'E2' = { 'E3' = { 'En' = 1 } }, 'E3' = {

Re: Unknown level of hash

2005-03-29 Thread Alexandre Jousset
Alexandre Jousset wrote: Andrew Pimlott wrote: (You should be able to write the first one as ${fold_left { \${$_[0]}-{$_[1]} } \$hash, @a} = 1; Is it a copy/paste or a retype ? Because there's a comma missing after the first closing brace... but Perl complains for no reason I can see.) --

Re: Unknown level of hash

2005-03-29 Thread Andrew Pimlott
On Tue, Mar 29, 2005 at 06:42:41PM +0200, Alexandre Jousset wrote: Alexandre Jousset wrote: Andrew Pimlott wrote: (You should be able to write the first one as ${fold_left { \${$_[0]}-{$_[1]} } \$hash, @a} = 1; Is it a copy/paste or a retype ? Because there's a comma missing

Re: Unknown level of hash

2005-03-29 Thread Luke Palmer
Zhuang Li writes: Yes. I think it's both useful and fun. I was thinking something similar to @[EMAIL PROTECTED] = map{1} @a; But getting $hash-{E1}-{E2}-...-{En} = 1; instead of $hash{E1} = 1; ... $hash{En} =1;. Yeah, like this: %hash{dims @a} = (1) xx Inf; What I'd really like to

RE: Unknown level of hash

2005-03-29 Thread Zhuang Li
-Original Message- From: Luke Palmer [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 29, 2005 5:43 AM To: Zhuang Li Cc: Jeff Yoak; fwp@perl.org; perl6-language@perl.org Subject: Re: Unknown level of hash Zhuang Li writes: Yes. I think it's both useful and fun. I was thinking