You should be able to build the array to as many dimensions as you want using recursion. I don't quite understand what you're doing (its also late and my brain is rebelling), but here is some incomplete code to give you the general idea.

my $ranges = [ { I => "2", }, { I => "3", J => "2", }, { I => "4", J => "3", K => "2", } ]; foreach my $rvarHASH ( @{ $ranges } ) { my @rvarLIST = sort keys %$rvarHASH; my $depth = scalar @rvarList; my $array = BuildArray(\@rvarLIST, $depth); # do whatever with $array ... } sub BuildArray{ my ($rvarLISTref, $depth) = @_; my $arrayref; $depth--; if ($depth > 0){ # last dimension not reached, so do another recursion my $rtn = BuildArray($rvarLISTref, $depth); # get index, set ref to next dimension in array $ii = ... $arrayref->[$ii] = \$rtn; }else{ # arrived at last dimension, # get index, set value into array $ii = ... $arrayref->[$ii] = $netlist; } return $arrayref; }

In reply to Re: multidimensional arrays by hangon
in thread multidimensional arrays by Anonymous Monk

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.