Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: How to better represent a complex data structure.

by choroba (Canon)
on Jan 08, 2013 at 16:10 UTC ( #1012268=note: print w/ replies, xml ) Need Help??


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

Fortunately, you do not have to make all the declarations. You can use anonymous arrays (and hashes):

my %main_file = ( USER => [ [], [], [] ], TEST => [ [], [], [] ], TRIM => [ [], [], [] ], );
If all the arrays are empty at the beginning, you do not have to declare anything - everything will be autovivified when dereferenced. So, in short:
my %main_file; push @{ $main_file{USER}[0] }, $string;
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ


Comment on Re: How to better represent a complex data structure.
Select or Download Code
Replies are listed 'Best First'.
Re^2: How to better represent a complex data structure.
by Amblikai (Beadle) on Jan 08, 2013 at 17:13 UTC

    Thanks! I was hoping that would be the case

    I'm still reading about autovivication and i was a little confused by it!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (16)
As of 2015-07-29 18:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (267 votes), past polls