in reply to Re: Binding an array to a word
in thread Binding an array to a word

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^3: Binding an array to a word
by Corion (Patriarch) on Aug 09, 2004 at 12:26 UTC

    A hash (also called "dictionary", or "map") only has one entry for every word. So you can't have two times the word "hello", the second time you insert it, it overwrites the first one.

      If you need hello to point to more than one array, you can do something like this:

      $h = { 'hello' => [ [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ], ], };

      To help you write the accompanying code...

      exists( $h->{'hello'}) # checks if hello exists. scalar(@{$h->{'hello'}}) # The number of lists (2). $h->{'hello'}[1] # The second list ([5,6,7,8]). scalar(@{$h->{'hello'}[1]}) # The size of the second list (4). $h->{'hello'}[1][0] # The first num of second list (5).