Hi monks, i'm trying to get my head around some more complicated data structures and i'm wondering how best to represent my data.

I hope i explain this ok but basically i have the following:

my @user_file_part1=(); my @user_file_part2=(); my @user_file_part3=(); my @test_file_part1=(); my @test_file_part2=(); my @test_file_part3=(); my @trim_file_part1=(); my @trim_file_part2=(); my @trim_file_part3=(); my @user_file=(\@user_file_part1, \@user_file_part2, \@user_file_part3); my @test_file=(\@test_file_part1, \@test_file_part2, \@test_file_part3); my @trim_file=(\@trim_file_part1, \@trim_file_part2, \@trim_file_part3); my %main_file=( USER <= \@user_file, TEST <= \@test_file, TRIM <= \@trim_file, );

So i have a hash of arrays of arrays if that makes sense (my brain is mush now!)

So my question after all that is, how can i better represent the above code? Do i have to make the array declarations before i take their reference or can i do that at the same time?

Also, if i wanted to push a value onto one of the end arrays, i.e. @user_file_part1, how would i reference it?

Like this?

push(@{$main_file{"USER"}[0]}, $string);

Thanks in advance!


In reply to How to better represent a complex data structure. by Amblikai

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.