Dr. Mu has asked for the wisdom of the Perl Monks concerning the following question:
(The obvious -- but wrong -- "clean" way gives %nums the keys 'FIRST', 'SECOND', 'FIFTH' instead of 1, 2, 5.) I know it's not World Peace, but is there a neater way to accomplish the hash assignment?use constant FIRST => 1; use constant SECOND => 2; use constant FIFTH => 5; %nums = ( @{[FIRST]} => 'Ein', @{[SECOND]} => 'Zwei', @{[FIFTH]} => 'Funf' ); print keys %nums
Thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Ugly syntax
by chipmunk (Parson) on Dec 04, 2001 at 10:27 UTC | |
by Dr. Mu (Hermit) on Dec 04, 2001 at 10:43 UTC | |
by perrin (Chancellor) on Dec 04, 2001 at 20:00 UTC | |
by gav^ (Curate) on Dec 04, 2001 at 21:26 UTC | |
by perrin (Chancellor) on Dec 05, 2001 at 02:28 UTC | |
by tye (Sage) on Dec 04, 2001 at 22:40 UTC | |
|
Re: Ugly syntax
by dws (Chancellor) on Dec 04, 2001 at 10:26 UTC |