in reply to Re: variable interpolation while dereferencing
in thread variable interpolation while dereferencing

Hi,

But i want to access the hash reference through a
variable as i don't know how deep it may go!

Like the following:

sub add_folder("Linux/Kernel") { # i want to do the foll. # $bkref->{folder}{Linux}{folder}{Kernel}{folder} = {}; }

So, the RHS may go to any size
and i can't hard code it
Can u help me out?

--
arc_of_descent

Replies are listed 'Best First'.
Re: Re: Re: variable interpolation while dereferencing
by fruiture (Curate) on Oct 27, 2002 at 12:03 UTC

    As hint:

    my $path = 'A/B/C'; my $hr = { 'A' => {'B'=>{'C'=>'Hello'}}}; my @path = split m</>,$path; my $ref = $hr; while(@path){ $ref = $ref->{ shift @path } } print "$ref\n"
    --
    http://fruiture.de

      thanx!
      I've spent my whole sunday morning and afternoon
      trying to get it to work!


      --
      arc_of_descent