in reply to Trying to understand the 'use constant' pragma

Assuming that you have control over MyObject.pm, perhaps the easiest solution is to use your constants internally to the module and accept a string in the constructor:

my $obj = MyObject->new(level=>'LOG_DEBUG');

You can use a hash to translate the level string to your internal code as required.


Perl is Huffman encoded by design.

Replies are listed 'Best First'.
Re^2: Trying to understand the 'use constant' pragma
by webengr (Pilgrim) on Sep 07, 2005 at 02:35 UTC
    This is a reasonable solution, and does what I originally intended. I was just wondering if there is a way of making the "use constant" effect extend further, but since the input from the xml file is text strings, this doesn't appear to be possible. Thanks!
    PCS