Given this code:
# a hash holding a reference to the array my %hash; print '$aref is ' . $aref ."\n"; $hash{'aref'} = $aref; print '$hash{\'aref\'} is ' . $hash{'aref'}. "\n"; # get h_ version of array reference my $h_aref = $hash{'aref'}; print 'array length is ' . scalar(@$h_aref) . "\n"; push @$h_aref, 'value 2'; print 'after 2nd push array length is ' . scalar(@$h_aref) . "\n"; print 'after 2nd push [0] array value is [' . $$h_aref[0] . "]\n"; print 'after push [1] array value is [' . $$h_aref[1] . "]\n"; # now try to access without intermediate $h_aref #print 'array length is ' . scalar(@$hash{'aref'}) . "\n"; # error #print 'array length is ' . scalar(@$$hash{'aref'}) . "\n"; # error
How do I access the array without the intermediate $h_aref?

---------------------------

It is indeed a curly braces thing
my %hash; print '$aref is ' . $aref ."\n"; $hash{'aref'} = $aref; print '$hash{\'aref\'} is ' . $hash{'aref'}. "\n"; # get h_ version of array reference my $h_aref = $hash{'aref'}; print 'array length is ' . scalar(@$h_aref) . "\n"; push @$h_aref, 'value 2'; print 'after 2nd push array length is ' . scalar(@$h_aref) . "\n"; print 'after 2nd push [0] array value is [' . $$h_aref[0] . "]\n"; print 'after 2nd push [1] array value is [' . $$h_aref[1] . "]\n"; # now try to access without intermediate $h_aref #print 'array length is ' . scalar(@$hash{'aref'}) . "\n"; # error #print 'array length is ' . scalar(@$$hash{'aref'}) . "\n"; # error print "now without the intermediate \$h_ref\n"; print 'array length is ' . scalar(@{$hash{'aref'}}) . "\n"; push @{$hash{'aref'}}, 'value 3'; print 'array length after 3rd push is ' . scalar(@{$hash{'aref'}}) . " +\n"; print 'after 3rd push [0] array value is [' . $hash{'aref'}[0] . "]\n" +; print 'after 3rd push [1] array value is [' . $hash{'aref'}[1] . "]\n" +; print 'after 3rd push [2] array value is [' . $hash{'aref'}[2] . "]\n" +;

Thanks to Data::Dumper and References quick reference

In reply to accessing array through array reference in hash by puff

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.