in reply to Hash values and constants

In the assignment to the hash, Perl does not know that 'TESTVALUE' is a constant, without an additional hint.

adding a '&' or () to the constants name, will be enough of a hint to give you the desired results.

#!/usr/local/bin/perl -w use strict; use Data::Dumper; use constant TESTVALUE1 => 1; use constant TESTVALUE2 => 2; use constant TESTVALUE3 => 3; my %hash; $hash{ TESTVALUE1 } = 'OK'; $hash{ &TESTVALUE2 } = 'OK'; $hash{ TESTVALUE3() } = 'OK'; print Dumper( \%hash );
Outputs:
:!./test.pl $VAR1 = { '2' => 'OK', 'TESTVALUE1' => 'OK', '3' => 'OK' };

Data::Dumper, is great when there is a doubt about what is happening inside of a data structure assignment.

Wonko