N
nadsinoz
I have a large script that contains a lot of subroutines. I would like
to pull the subs out into a separate file for each sub. Each sub still
needs to be called from my main script, and have access to the global
variables of the main script:
CURRENT:
mainscript.pl
-------------------
my $var1;
my $var2;
&subA();
&subB();
sub A { print $var1 };
sub B { print $var2 };
REQUIRED:
mainscript.pl
-------------------
my $var1;
my $var2;
&packageA::subA();
&packageB::subB();
packageA.pm
--------------------
print $var1;
Question:
within packageA.pm, how can I use var1 from mainscript without having
to explicity pass it in to the sub?
Many thanks ....
to pull the subs out into a separate file for each sub. Each sub still
needs to be called from my main script, and have access to the global
variables of the main script:
CURRENT:
mainscript.pl
-------------------
my $var1;
my $var2;
&subA();
&subB();
sub A { print $var1 };
sub B { print $var2 };
REQUIRED:
mainscript.pl
-------------------
my $var1;
my $var2;
&packageA::subA();
&packageB::subB();
packageA.pm
--------------------
print $var1;
Question:
within packageA.pm, how can I use var1 from mainscript without having
to explicity pass it in to the sub?
Many thanks ....