Instead of
push @structure->[$i], $ex[$i];
You need
push @{ $structure->[$i] }, $ex[$i];
Which reads as; Use the $ith element of the array pointed at by the reference in the variable $structure as an array reference and then push the value of $ex[$i] onto that array.
The basic form is that in ?{ $ref }, that if $ref contains a reference to an aggregate datastructure (array or hash) then ?{ $ref }, where ? is either @ or %, allows you to use that data structure. (Hmm. That probably doesn't clarify anything!)
If $ref is an array ref, then @{ $ref } is the array it's referencing. Like wise for hashrefs and %{ $ref }.
There are shortcut versions of this syntax. If the reference is a simple scalar then you can omit the curlies: @$ref, but when the reference is itself a member of an aggregate, that doesn't work. I tend to use the full @{ $ref } syntax always. For both consistancy and because I don't have to remember when the shortcur does and doesn't work.
To get a better understanding of using references see perlreftut, perdsc and/or do a Super Search for "Tutorials references" here at PM.
Sorry for these naive questions.
Don't be. Leastwise, not for my sake. The only people who get upset about naive questions are those that either a) received their knowledge as a result of genetic imprinting; b) have forgotten that they once didn't know what they now know.
In either case, it's just intellectual snobbery--the very worst kind.
In reply to Re^7: Best complex structure?
by BrowserUk
in thread Best complex structure?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |