I'll add some java to the mix:

package Foo; import java.util.HashMap; public class Bar { public static void main(String... args) { HashMap<String, HashMap<String, Integer>> map = new HashMap<Stri +ng, HashMap<String, Integer>>(); map.put("A", new HashMap<String, Integer>()); map.get("A").put("A", 1); map.get("A").put("B", 2); map.put("B", new HashMap<String, Integer>()); map.get("B").put("A", 4); map.get("B").put("B", 8); for(String k: map.get("B").keySet()) { System.out.println(k + " - " + map.get("B").get(k)); } } }

Java would be the language I use most after Perl. When using Java, I often think about how much I miss the first class support for lists and hashes that we have in Perl. But, I find that when I don't have that first class support, I write things differently anyhow. If it is harder to make and use a hash, I won't use a hash as often.

That being said, I really love Java's hierarchy of collections. There are many powerful types of lists and hashes, and Generics really simplify things.

Ted Young

($$<<$$=>$$<=>$$<=$$>>$$) always returns 1. :-)

In reply to Re: Multidimesional hashs in Perl, C++, C# and Perl6 by TedYoung
in thread Multidimesional hashs in Perl, C++, C# and Perl6 by bsdz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.