accessdenied has asked for the wisdom of the Perl Monks concerning the following question:
Hi.
I would like to create a constant but it's value is known only in runtume.
I did like this:
my $someVar = "someValue"; use constant CNST => $someVar;
but running this code
print('Got const [', CNST, ']');I got warning "use of uninitialized ..." and brackets are empty - [].
Is there any way to initialize constant like I want?
What I'm trying to do is having some object which is defined in the module and which can be used from script which uses this module but in readonly mode.
I can define our $var which will be available with $MODULE::var but this allow to change value and I would like to avoid change.
|
|---|