I would like to set up a dedicated package for all common declarations to main perl program and other packages as well, without repeating these declarations in every headers. I get it wrong for sure but could not figure out the rationals behind that :
Let's assume :
- I have setup my common data within the package my_common_declarations.pm.
- I want to use these data within another package, my_perl_utils.pm for example.
#!/usr/bin/perl -w
package my_perl_utils;
use parent qw(Exporter);
our @EXPORT_OK = qw(f1 f2);
use my_common_declarations qw(debugme);
my %setup = &debugme;
my $DEBUGME = $setup{setup}{debugme};
# This generates this error : "Use of uninitialized value"
use constant true => $setup{setup}{'true'};
print "=" x25, "\nDEBUG true :\nimport = " . $setup{setup}{'true'} . "\nconstant = " , true , "\n", "=" x25, "\n";
sub f1{
# some rationals using the true or false constants
}
sub f2{
}
1;
I can't succeed in getting the 'true' constant declared without errors.
Shall I import the common declarations package only once in the main program and declare the constant accordingly in there, or redeclare it within each package where I need this constant ?
thx