I am using the Config::Simple module and the constant pragma. I am parsing a configuration file and setting the values as constant. the test configuration file (test.ini) contains:
POP3SERVER='192.168.1.1'
when I am running the follow perl statements:
use warnings;
use strict;
use Config::Simple;
my %Cnf;
Config::Simple->import_from('test.ini', \%Cnf);
use constant TEST => scalar $Cnf{"default.POP3SERVER"};
print $Cnf{"default.POP3SERVER"},"\n";
print TEST . "\n";
I get the following lines:
192.168.1.1
Use of uninitialized value in concatenation (.) or string at ./algo.pl line 10.
The hash contains the information, you can see it in the first print but when assigned in the constant statement is not set
What am I doing wrong on the code??
thnx
“use” happens at compile time, calling import_from() happens at run time (ie after the use).
Wrap the call to import_from in a BEGIN block: