Re: Hashes of Hashes



"JS" == Jen Spinney <jen.spinney@xxxxxxxxx> writes:

JS> If you want to make hashes of hashes or any other complex data
JS> structure like that, you probably want to be using references. Perl
JS> flattens arrays/hashes contained in another array/hash. That is, (1,
JS> 2, 3, 4, (1, 2, 3)) is the same as (1, 2, 3, 4, 1, 2, 3). Take a look
JS> at perldoc perldsc and/or perldoc perlreftut. You might also want to
JS> use the Data::Dumper module to take see what your data structures
JS> actually look like (so you know you've done it correctly). If you add

the OP IS using references but doesn't know it. and there is no
flattening going on anywhere. the problem is that he assigns a regular
scalar value to some node in his data tree and also assigns a hash ref
(the .003 stuff) to the same node overwriting it (depending on the order
he does them). a given node can have a single value which can be a
scalar value OR a reference to another level but not both.

uri

--
Uri Guttman ------ uri@xxxxxxxxxxxxxxx -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
.



Relevant Pages

  • Re: Dynamic Hash
    ... Please read the documentation on hashes before making assumptions about how they look. ... Perl provides no alternate means of handling the issue. ... The program structures were never strings per-se, in the same sense as data ... This does not get as deeply nested as a directory tree, of course, but you should be able to see how references link together ...
    (perl.beginners)
  • Re: Perl is awsome!
    ... > Scalars, arrays, hashes, references, modules... ... > Perl is so cool! ... That message is a fake. ...
    (comp.lang.perl.misc)
  • Perl is awsome!
    ... Scalars, arrays, hashes, references, modules... ... How about Perl++? ...
    (comp.lang.perl.misc)
  • Re: When to "use strict" when teaching?
    ... >>being influenced by the history of Perl ... history bias you" essentially the same as saying you are not ... An understanding of how symbolic references work is neither necessary ... I say don't expose people to the idea of omitting "use strict" until ...
    (comp.lang.perl.misc)
  • Re: Creating a list of HASHes
    ... > Declare your variables in the smallest possible scope. ... This is another thing I have a tenious grasp of, hashes, ... > I would prefer to use references to hashes all around. ... time to properly formulate a question will most likely get me a proper ...
    (comp.lang.perl.misc)