Hi all !
I've made a structure that uses 3 levels of hashes. It works nice but creating these levels requires a lot, and I mean a lot, of typing per each element. See:
$project{$activeProject}->{components}->{"Software"}->{subComponents}-
+>{"Database"}->{label} = "Test-1.01";
That's one element. And it has a lot of elements at different levels. There must be a way in Perl to reduce this amount of typing while retaining the structure. I tried equating part of it, like this:
sub readItem {
my $subDatabase = $project{$activeProject}->{components}->{"Software"}
+->{subComponents}->{"Database"};
print "$subDatabase->{label}";
}
And while this works when printing elements, it simply does not write anything to the structure when used to initialize data (I think that's because $subDatabase is local to a subroutine...)
Anyhow, I'd really appreciate any suggestions regarding typing less to initialize data in such extensive structures. I'd go for an object-oriented approach if needed.
Cheers.
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.