I have a somewhat novice question about creating a tree structure out of a flat set of data. I basically want to take a number of arrays and store them in one structure.
To start with, I need to know how to store an array of values in another array, in code like this:
sub recursive_store {
$query[$level] = "sql code here";
$query[$level]->execute;
while((_STORAGE[$level])=$query[$level]->fetchrow_array) {
print _STORAGE[$level][0];
}
}
&recursive_store($level);
I'm not sure what syntax to use for storing and then retrieving the arrays returned by the while condition. The purpose is then to be able to go:
print _STORAGE[$anylevel][$anyindex];
Basically I need to access an array of arrays but the samples I've seen weren't really clear on how to achieve that.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.