Lya has asked for the wisdom of the Perl Monks concerning the following question:
The output is:use constant { NULL => 0, EINS => 1, ZWEI => 2, }; my %english_translation = ( NULL => "Zero", EINS => "One", ZWEI => "Two", ); foreach ( keys %english_translation ) { print "$_ = $english_translation{$_}\n"; }
But I want to have something like:EINS = One NULL = Zero ZWEI = Two
Why aren't the constants substituted in the Hash-Definition or how can I use constants that are doing what I want?0 = Zero 1 = One 2 = Three
Thanks, Barbara
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Module constant and constants in Hashes
by Corion (Patriarch) on Jan 14, 2009 at 14:43 UTC | |
by Fletch (Bishop) on Jan 14, 2009 at 14:51 UTC | |
by Lya (Initiate) on Jan 14, 2009 at 14:57 UTC | |
by jdporter (Paladin) on Jan 14, 2009 at 15:37 UTC | |
by shmem (Chancellor) on Jan 14, 2009 at 21:34 UTC | |
by tinita (Parson) on Jan 15, 2009 at 15:14 UTC | |
Re: Module constant and constants in Hashes
by borisz (Canon) on Jan 14, 2009 at 14:49 UTC | |
Re: Module constant and constants in Hashes
by zentara (Cardinal) on Jan 14, 2009 at 14:51 UTC | |
by Lya (Initiate) on Jan 14, 2009 at 15:05 UTC | |
by zentara (Cardinal) on Jan 14, 2009 at 15:16 UTC |