Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: How to better represent a complex data structure.

by BrowserUk (Pope)
on Jan 08, 2013 at 16:19 UTC ( #1012274=note: print w/ replies, xml ) Need Help??


in reply to How to better represent a complex data structure.

Do i have to make the array declarations before i take their reference or can i do that at the same time?

You do not need to declare (or even name) the arrays at all.

When you push or assign to a complex data structure the intermediate aggregates will be autovivified (Ie. created if they do not yet exist.):

my %main_file; push @{ $main_file{ USER }[ 1 ] }, 'fred'; push @{ $main_file{ TEST }[ 3 ] }, 'bill'; push @{ $main_file{ TRIM }[ 0 ] }, 'john'; pp \%main_file;; { TEST => [undef, undef, undef, ["bill"]], TRIM => [["john"]], USER => [undef, ["fred"]], }

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.


Comment on Re: How to better represent a complex data structure.
Download Code
Re^2: How to better represent a complex data structure.
by Amblikai (Beadle) on Jan 08, 2013 at 17:15 UTC

    Thanks!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1012274]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2014-09-20 08:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (157 votes), past polls