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

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.

Replies are listed 'Best First'.
Re^4: Binding an array to a word
by Anonymous Monk on Aug 09, 2004 at 18:45 UTC

    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).