in reply to Pulling Array Out of Hash Reference

You are very close:
print @{ $hashRef->{'a','d'} };
To satisfy operator precedence, the braces are needed in the array dereference.

-Mark

Replies are listed 'Best First'.
Re: Re: Pulling Array Out of Hash Reference
by antirice (Priest) on Apr 12, 2004 at 23:05 UTC

    I believe you meant:

    print @{ $hashRef }{'a','d'};

    Your code attempts to deref $hashRef->{join $;,'a','d'} which is undefined.

    antirice    
    The first rule of Perl club is - use Perl
    The
    ith rule of Perl club is - follow rule i - 1 for i > 1

      Which can also be written as

      print @$hashRef{'a','d'};

      as outlined in references quick reference (which is how I finally figured out that all of this syntax is pretty easy to keep straight).

      But I think I'd stick with

      print @{$hashRef}{'a','d'};

      as being clearer.

      - tye        

        Yes, but I normally use @{hashref}{LIST} since it puts me in the habit of not doing something goofy like trying to change

        @$hashRef{LIST}

        into

        @$array_ref->[INDEX_OF_HASHREF]{LIST}

        during those late night coding sessions.

        antirice    
        The first rule of Perl club is - use Perl
        The
        ith rule of Perl club is - follow rule i - 1 for i > 1

      Blush, a bad test on my part. You are entirely correct.

      -Mark