In this case, $h should be defined as:my $h = f(qw[ foo => zoo moo too bar => car far bar => zar tar qux => mux ]);
Note that the input can be anything at all, provided it is in list format, and the keys are valid keys, and that further the symbol '=>' is reserved as an identifier. There may be key conflicts with the key, in which case the new data is appended to the existing data, as shown in the example with 'bar'.$h = { foo => [ 'zoo','moo','too','bar' ], bar => [ 'car','far','zar','tar' ], qux => [ 'mux' ] };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (Golf) List to Hash
by davisagli (Scribe) on Jul 31, 2001 at 17:43 UTC | |
|
Re: (Golf) List to Hash
by Masem (Monsignor) on Jul 31, 2001 at 17:13 UTC | |
|
Re: (Golf) List to Hash
by tachyon (Chancellor) on Jul 31, 2001 at 18:56 UTC | |
|
(ichimunki)re: List to Hash
by ichimunki (Priest) on Jul 31, 2001 at 17:09 UTC |