Chas. Owens wrote:
SOME_CONSTANT is being interpreted as the string "SOME_CONSTANT".
Why is it so? This is crazy.
This is one of the drawbacks to the constant pragma. Change the code hash keys to one of these and it will work the way you want it to: $hash{+SOME_CONSTANT} #unary plus
What is this unary plus?
$hash{&SOME_CONSTANT} #function call method 1 $hash{SOME_CONSTANT()} #function call method 2 However, I would suggest using the ReadOnly* module for constants instead. * http://search.cpan.org/dist/Readonly/Readonly.pm
Thanks. Hmm, they say it is slow (http://search.cpan.org/dist/Readonly/Readonly.pm#CONS).
Why aren't there constants in the language itself?? This is crazy.Also: is that true that Perl's specification is its implementation by Larry Wall? This is even more crazy. :-/
A language and its implementation are (should be) 2 different things! Gunnar Hjalmarsson wrote:
So, what behavior exactly is it that you consider weird? What output had you expected?
I'd expect equal hash keys to map to equal values. I'm a conservatist. :-) STF ======================================================================= http://eisenbits.homelinux.net/~stf/ . My PGP key fingerprint is: 9D25 3D89 75F1 DF1D F434 25D7 E87F A1B9 B80F 8062 =======================================================================
signature.asc
Description: OpenPGP digital signature