in reply to Re^2: create an anonymous hash using "map"
in thread create an anonymous hash using "map"
It's the difference between run time vs compile time behavior.
use will execute at compile time, so does your construct. Any code you depend on to be run before must also be executed at compile time, like in a BEGIN block.
See perlmod for more on execution phases.
And here a suggestion which seems best to be maintained IMHO.
(untested hack into mobile browser)
my %characters; BEGIN { my $char = 0xE000; %characters = map { $_ => $char++ } ( 'first character', 'second character', 'third character' ); } use charnames ":alias" => \%characters;
you may also consider putting your rather complicated specialized configuration array into a module of your own, which is executed with use
This will automatically happen at compile time, and provide you with a clean interface
Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery
|
---|