Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Complex Data Structures

by thelenm (Vicar)
on Jun 18, 2002 at 17:00 UTC ( #175425=note: print w/replies, xml ) Need Help??


in reply to Complex Data Structures

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}

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (1)
As of 2021-03-01 04:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?