Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-19 22:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found