carcassonne has asked for the wisdom of the Perl Monks concerning the following question:
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:$project{$activeProject}->{components}->{"Software"}->{subComponents}- +>{"Database"}->{label} = "Test-1.01";
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.sub readItem { my $subDatabase = $project{$activeProject}->{components}->{"Software"} +->{subComponents}->{"Database"}; print "$subDatabase->{label}"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using multi-level hashes
by QM (Parson) on Oct 28, 2005 at 22:32 UTC | |
|
Re: Using multi-level hashes
by shemp (Deacon) on Oct 28, 2005 at 21:39 UTC | |
|
Re: Using multi-level hashes
by Roy Johnson (Monsignor) on Oct 28, 2005 at 21:32 UTC | |
|
Re: Using multi-level hashes
by Zed_Lopez (Chaplain) on Oct 28, 2005 at 21:32 UTC | |
|
Re: Using multi-level hashes
by friedo (Prior) on Oct 28, 2005 at 21:36 UTC | |
|
Re: Using multi-level hashes
by ioannis (Abbot) on Oct 29, 2005 at 01:28 UTC | |
|
Re: Using multi-level hashes
by metaperl (Curate) on Oct 28, 2005 at 22:03 UTC | |
|
Re: Using multi-level hashes
by zentara (Cardinal) on Oct 29, 2005 at 11:48 UTC | |
|
Re: Using multi-level hashes
by JamesNC (Chaplain) on Oct 29, 2005 at 20:58 UTC | |
|
Re: Using multi-level hashes
by perlfan (Parson) on Nov 01, 2005 at 05:07 UTC |