Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
When my data structures start getting too complex, I usually see if there's a way I can pull some of the data manipulation (and even the data itself) into a module. Many times I've come back to a program after a few months and said, "Well, it looks like a hash of arrays of hashes of hashes, but what the heck does that mean?" I find it helpful to use functions or object methods to manipulate those data so that I can say something like
$purchase_table->add_purchase($customer, $basket, $purchase_id, $value +);
instead of
$purchases->{$customer}->[$basket]->{$purchase_id} = $value;
That way, I not only understand exactly what's going on, but I'm also less likely to screw myself up by manipulating the large structure differently in different places in the code. And I can change the actual implementation without changing the function/method calls.

And as jeffa mentioned, Data::Dumper is a lifesaver. :-)

-- Mike

--
just,my${.02}


In reply to Re: Complex Data Structures by thelenm
in thread Complex Data Structures by random

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 imbibing at the Monastery: (6)
As of 2024-04-16 10:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found