I think one problem is the libraries are loaded before the variables are made available but putting them in BEGIN breaks stuff.
I wonder what exactly you have tried, and how BEGIN did break stuff. As you suspected, initialising the variables in a BEGIN block should work to get the values passed to the lib.
A heavily simplified snippet might help ($foo represents $LOGFH etc. that you want to pass to the lib):
#!/usr/bin/perl -w use strict; my $foo; BEGIN { $foo = "bar" } use License ($foo);
with License.pm being
package License; use strict; my $foo; sub import { shift; $foo = $_[0]; print "foo = $foo\n"; } 1;
should print "foo = bar" when the main program is being run.
Note that $foo has to be declared outside of the BEGIN { }, because the latter implies an extra block scope.
Another way would be to use require instead of use and call the import method explicitly:
my $foo = "bar"; require License; License->import($foo);
In this case, the three statements would be executed at runtime in the sequence they appear, so $foo would be properly initialised before the import method is being called.
In reply to Re: many files one log file
by Eliya
in thread many files one log file
by glenn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |