Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Complex Data Structure

by Neighbour (Friar)
on May 21, 2012 at 14:49 UTC ( #971636=note: print w/ replies, xml ) Need Help??


in reply to Complex Data Structure

Well, by the looks of it, it's a hash (%Data) which references another hash (with keys Rank and Salary), which references an array (where you push your datasets into). Depending on what's *in* that dataset it could go on, but for now you have a hash-of-hashref-of-arrayref :)
You could make it more elegant and use a hashref to start with (so use $Data->{$Name} instead of $Data{$Name} and don't initialise it with my %Data but my $Data) in which case you'll end up with a hashref-of-hahref-of-arrayref (or HRHRAR :P)

As for the aestetics, there's a program for that (there usually is) called perltidy. It has more rules than you will initially care for, but once you've got your personally approved configuration set up, you can convert all perl codefiles that come your way to the layout you prefer.


Comment on Re: Complex Data Structure
Select or Download Code
Re^2: Complex Data Structure
by Anonymous Monk on May 21, 2012 at 14:52 UTC
    Great exactly what i was looking for. One thing - why should I initilise it with $Data and not %Data?
      Stupid question I get it.. Thanks

      No reason I'm aware of; just a matter of personal preference. I tend to use a hash variable rather than a hashref at the top level to save typing arrows ( $data{level1}{level2} instead of $data->{level1}{level2} ) unless it's a reference to an object or I'm going to be passing it as a reference to a lot of functions or something, in which case I'll save a little typing by passing $data instead of \%data. So it really just depends on how I'll be using it.

      Aaron B.
      Available for small or large Perl jobs; see my home node.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (10)
As of 2014-04-23 17:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (549 votes), past polls