- I am integrating a logging framework to my perl project which has around 300 Perl files.
- So I have written a module
Logging.pm
which has overriddendie
,say
,warn
functionalities and sinceprint
cannot be overridden I have tied it my custom handle. - I have a master script
execute.pl
which executes all the scripts throughsystem
/qx
/exec
. - I want to include
Logging.pm
in justexecute.pl
and all the functionalities ofLogging.pm
should be availabe in the child process executed by execute.pl throughsystem()
orqx()
orexec()
.
Example of Execution:
execute.pl -> system("test1.pl") -> system("test2.pl")
So the test1.pl
and test2.pl
should pick up the overridden die/warn/say/print
if I just include Logging.pm
in excute.pl
.
As far I know system/qx/exec
will be OS call and Logging.pm
won't be available in the child process, is there any way I can achive this as I don't want to edit 300 files?
Since the sub-processes are entirely separate processes they will not keep any modules loaded by the parent process.
One possibility to solve this is to set the
PERL5OPT
environment variable. This variable can hold extra command line flags for the Perl interpreter. However, this will affect all Perl processes started directly or indirectly by your script, not just those scripts that are part of your project.To automatically
use Logging
, you'd add-MLogging
to thePERL5OPT
. In shell:or
or within
execute.pl
: