in reply to constant not evaluated

use constant EARL => 'MEL';
is (functionally) identical to the code
sub EARL () { 'MEL' }

The problem is that you're using it in a stringifying context - the left-hand side of the => operator. Try the following:

my $b = { EARL() . HARRIS() => 55 };
And see if it does what you want.

------
We are the carpenters and bricklayers of the Information Age.

Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

I shouldn't have to say this, but any code, unless otherwise stated, is untested

Replies are listed 'Best First'.
Re^2: constant not evaluated
by Roy Johnson (Monsignor) on Sep 20, 2004 at 19:08 UTC
    To depend less on how constants are implemented, just put the argument that is being stringified (before being constant-evaluated) in parentheses:
    my $b = {EARL.(HARRIS) => 55 };
    And of course, using a comma instead of the stringification operator also yields the desired result.
    my $b = {EARL.HARRIS, 55 };

    Caution: Contents may have been coded under pressure.
Re^2: constant not evaluated
by esharris (Monk) on Sep 20, 2004 at 19:17 UTC
    Thanks for the reply. This did fix the problem.