In article <[EMAIL PROTECTED]>,
        Bart Lateur <[EMAIL PROTECTED]> writes:
> On Thu, 18 Apr 2002 12:42:17 -0500, c. church wrote:
> 
>>$hash{foo}{bar}{baz} is extrmely descriptive.  I
>>like it.  I can look in once place and see exactly what I need.
> 
> Yeah... but what I don't like, is that if I have an array (or list):
> 
>       @follow = ('foo', 'bar', 'baz');
> 
> that I can't have a simple expression with \%hash and @follow which will
> look up the above expression or me. All I can do, is create a loop that
> follows each ref:
> 
>       my $ref = \%hash;
>       foreach (@follow) {
>           $ref = $ref->{$_};
>       }
> 
> and in the end, $ref will contain the value I want. Er, it will contain
> a *copy* of the value, I can't modify the original hash element using
> it.
> 
> Complicated, or what?
> 
Loop like this:
        my $here = \\%hash;
        $here = \${$here}->{$_} for @follow;
        # Now you can really access that spot (even if it didn't exist before)
        $$here = $value;

Reply via email to