okay, Popcorn Dave, here's a little example, with comments. it's a little different from your example, but i think you can follow my example. if you're attempting data structures this complex, i hope you've read perlref, perlreftut, and perldsc.

i've used strict: don't code without it. it offers protection from many problems you might encounter during development.

#!/usr/bin/perl -w use strict; ## constants: i don't like 'use constant MAX => 3;', so... sub MAX() { 3 } sub SLICE() { 0 .. 1 } ## create empty hash reference ## ref to hash my $table_ref = {}; ## create some empty hashes ## ref to hash of hashes $table_ref->{$_} = () for( 0 .. MAX ); for( 0 .. MAX ) { if( $_ % 2 ) ## ref to hash of hashes holds scalar value { $table_ref->{$_}{shape} = 'rect' } else ## ref to hash of hashes holds scalar value { $table_ref->{$_}{shape} = 'circle' } ## ref to hash of hashes dereferenced as array, assign list @{ $table_ref->{$_}{coords} } = ( 0 .. MAX ); } for( sort keys %{ $table_ref } ) { print "Key: $_ Value: $table_ref->{$_}\n"; print "Shape $table_ref->{$_}{shape}\n"; ## ref to hash of hashes dereferenced as array, grab a slice print $_ for( @{ $table_ref->{$_}{coords} }[ SLICE ] ); print "\n"; }

~Particle *accelerates*


In reply to slice of ( ref of HoH dereferenced as array ) by particle
in thread Correct syntax to access an array slice within a hash within a hash by Popcorn Dave

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.