in reply to Re: Forcing Array Context
in thread Forcing Array Context

Thanks for the reply.

If I were to then return \%hierarchy to a scalar variable how would I go about printing out the results?

Replies are listed 'Best First'.
Re: Re: Re: Forcing Array Context
by ViceRaid (Chaplain) on Jun 25, 2003 at 10:05 UTC

    I suggest you take a look at the tutorials broquaint suggested; this should all become less mysterious. As for your question, the same principle applies as above: if you've got a reference in $ref put the sigil for the relevant type before it to dereference it. You'll get something like %$ref, @$ref, $$ref.

    my $hierarchy = get_hierarchy(@dirs); while ( my ( $directory, $contents ) = each %$hierarchy ) { ... # do your thing here }

    ViceRaid

Re: Re: Re: Forcing Array Context
by Anonymous Monk on Jun 25, 2003 at 09:57 UTC

    I think I've got it:

    for (keys %{ $scalar }) { print "$_\n" for @{$_}; }

    Does that look right?

      Yep, that's what you want. Sorry, I missed this post before posting below.

        Thanks :)