in reply to Constant name stored in a string

That's not trivial. Defining a constant using the constant pragma means a subroutine with that name is created - a subroutine without a prototype.

Now, it's fairly easy to test if there's a subroutine defined given a name, and it's also fairly easy to see whether it has an empty prototype. But not every function with an empty prototype is a constant.

So, you may have to resort to introspection tools like Devel::Peek. It's Dump function can tell whether a subroutine is a constant - look for the CONST flag. Dump writes to STDERR, so if you want to do this from within your program, you may want to redirect STDERR and capture it yourself.

Replies are listed 'Best First'.
Re^2: Constant name stored in a string
by WizardOfUz (Friar) on Jan 28, 2010 at 16:54 UTC

    Or you could examine %constant::declared.