|Keep It Simple, Stupid|
Always bear in mind that Perl is a pragmatic language, built “out of necessity” Lots of people (from “Larry Wall, himself” on forward) have faced the same problems that you did, and developed a pragmatic way to solve them.
In (this | your | their) case, the “magic pixie dust” is called references. The apparent “complexity” of your situation in-fact arises from the fact that you need to insert “a complex data-structure” into one and only one place. This requirement is very elegantly (and very completely ...) handled by the singular notion of “a reference,” which is: “a single thing” (i.e. it can exist “in one place”) that can refer to (ommmm.....) anything-at-all. (Furthermore, you can have any number of references to the selfsame thing ... so it can be in more than one place at the same time, if you so desire.)
The next key to this puzzle is ... that you can express this key notion without a bunch of extra steps. In other words, without declaring a bunch of extra, otherwise-unnecessary variables. Instead of “first” declaring @whatever and then later referring to \@whatever, you can simply describe what you really want, in one pragmatic step, and Perl will understand.
The Perl language is, after all, a human tool, that was originally conceived by someone who “had a job to ‘get done’,” and who devised the most-straightforward (to him... at the time ...) way, by which he could persuade a digital computer(!!) to do it. (And hundreds if not thousands of other kindred souls, faced in their turn with the selfsame objective, have surely labored upon it since.)
Fact is... “Representing a complex data structure” is par for the course to every single one of us, from Larry Wall on down. We’ve gotten very good at it. ;-)
In reply to Re: How to better represent a complex data structure.