It's looks like you've got at least five levels there, not three. First, here's a tip that will save you a few keystrokes. Once you're "in" a complex structure, you don't need to type the
-> operator to dereference. So
$project{$activeProject}->{components}->{"Software"}->{subComponents}-
>{"Database"}->{label}
can be written
$project{$activeProject}{components}{Software}{subComponents}{Database}{label}
You were on track for adding elements to the hash without typing the entire structure each time. To add stuff to that final level, you can do:
$subDatabase->{label} = "whatever";
$subDatabase->{foobar} = "something else";
Since $subDatabase is a reference to the original structure, the changes will persist after you leave the sub (assuming %project is defined outside the sub's scope, as it appears.)
Note: It's always a good idea, but especially when working with complex data structures, to turn strict and warnings on, if you haven't already.
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.