in reply to Re: Re: Problem with constant pragma and some hash definitions
in thread Problem with constant pragma and some hash definitions

Actually there is. As soon as you add that ampersand the constants cease to be constants. And instead of inlining the value during compile-time, Perl actually calls the functions each time. Therefore I'd rather add an empty pair of braces:

%hash = ( FOO() => 'FOO description, ...)
Try to run these three and see the difference:
perl -MO=Deparse -e "use constant FOO => 5; print FOO,qq{\n};" perl -MO=Deparse -e "use constant FOO => 5; print &FOO,qq{\n};" perl -MO=Deparse -e "use constant FOO => 5; print FOO(),qq{\n};"

Jenda
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
   -- Rick Osborne

Edit by castaway: Closed small tag in signature

Replies are listed 'Best First'.
Re^4: Problem with constant pragma and some hash definitions
by particle (Vicar) on Jul 21, 2003 at 12:59 UTC

    there is another option you left out, which makes use of the unary "+" operator.

    perl -MO=Deparse -e "use constant FOO => 5; print +FOO,qq{\n};"

    which parses correctly. this syntax is idiomatic, and is the method i would prefer.

    ~Particle *accelerates*