go ahead... be a heretic | |
PerlMonks |
Re^3: Unfolding a nDeep structureby blokhead (Monsignor) |
on Jul 05, 2007 at 23:13 UTC ( [id://625149]=note: print w/replies, xml ) | Need Help?? |
If I understand right (from looking at your example code in the OP), you want a structure that looks like this:
In other words, $AoA[x] contains all the elements of the form $MDA[x][*][*], if you follow my notation. I don't see how this corresponds with your "Expected" data, but one thing I noticed is that you should make the following change: Because when dealing with $AoA[$level], you only care about things starting form $MDA[$level]. Also, then $val will not be an arrayref like it was before. There are many equivalent ways to write this, but another way is the following: Here you can replace the entire foreach loop with this: To explain this, it takes everything of the form $MDA[a][b][c] and pushes it onto the array at $AoA[a]. blokhead
In Section
Seekers of Perl Wisdom
|
|