Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

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.

Replies are listed 'Best First'.
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?

      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.

      Stupid question I get it.. Thanks

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://971636]
[Corion]: Veltro: This is due to the fact that one of our webservers doesn't have "our" https certificate but another https certificate. Work is underway (well, on my long, long to-do list) to switch even that server over to "our" certificate
[Veltro]: Corion OK, thanks. At least I understand it now.

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (12)
As of 2018-05-23 11:24 GMT
Find Nodes?
    Voting Booth?