in reply to use constant for strings

The problem is your use of the stringifying comma (=>). The parser sees it following a bareword, and assumes that you want the string value "WISCONSIN" rather than the return value of the subroutine &WISCONSIN().

There are various ways around this: you can change the fat comma to a regular comma, or you can change the bareword into something Perl recognizes as subroutine call (since that's what a constant is actually implemented as).

my %capitol_map = ( WISCONSIN , "Madison", ILLINOIS , "Springfield", ... );
or
my %capitol_map = ( &WISCONSIN => "Madison", ILLINOIS() => "Springfield", ... );

Update: it has been suggested that both of these have the potential to confuse future readers of your code, which I find a strong enough argument to recommend against using this particular construct. Use the skinny comma or dws's suggestion above, instead. </update>

I was going to suggest %map = ( +WISCONSIN => "Madison"), but that doesn't actually do the trick with my perl. It does, however, work for getting keys back out of the hash, should you ever need to:

print $capitol_map{+WISCONSIN};



If God had meant us to fly, he would *never* have given us the railroads.
    --Michael Flanders