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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |