in reply to Re: Pulling Array Out of Hash Reference
in thread Pulling Array Out of Hash Reference

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

Replies are listed 'Best First'.
Re^3: Pulling Array Out of Hash Reference
by tye (Sage) on Apr 12, 2004 at 23:24 UTC

    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

Re: Re: Re: Pulling Array Out of Hash Reference
by kvale (Monsignor) on Apr 12, 2004 at 23:22 UTC
    Blush, a bad test on my part. You are entirely correct.

    -Mark