1) Initialize a nDeep structure with zeros:
2) Do stuff with the structure, add data, etc.#!/usr/bin/perl -w use strict; my $deeepness = 5; my @nDeep = (); my $dimention = 5; for my $deep0 (0..$dimention-1) { for my $deep1 (0..$dimention-1) { for my $deep2 (0..$dimention-1) { for my $deep3 (0..$dimention-1) { for my $deep4 (0..$dimention-1) { $nDeep[$deep0][$deep1][$deep2][$deep3][$deep4] = 0 +; } } } } }
3) Unfold the structure into a 2D array:
I would be interested in this all happening only by specifying a deepness level (my $deepness = 5 in this case).for my $deep0 (0..$dimention-1) { for my $deep1 (0..$dimention-1) { for my $deep2 (0..$dimention-1) { for my $deep3 (0..$dimention-1) { for my $deep4 (0..$dimention-1) { push @{$AoA[$deep0]}, $nDeep[$deep0][$deep1][$deep +2][$deep3][$deep4]; } } } } } for my $row (0..$#AoA) { print "@{$AoA[$row]}\n"; }
Thanks for sharing your enlightening knowledge and your time, always very much appreciated.
Frank
In reply to Unfolding a nDeep structure by FFRANK
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |