mymain.pl
#!/usr/bin/perl
use strict;
my ($a,$b,$c);
require 'load_vars.pl';
require 'myutilities.pl';
print "start: I am in mymain.pl\n\n";
($a,$b,$c) = &load_vars;
&myutilities($a);
print "end: I am in mymain.pl\nand n mymain the variables loaded are:\na=$a\nb=$b\nc=$c\n";
load_vars.pl
#!/usr/bin/perl
use strict;
sub load_vars {
print "loading variables... I am in load_vars.pl now\n\n";
my $a = 'apple';
my $b = 'banana';
my $c = 'cherry';
return ($a,$b,$c);
}
1;
myutilities.pl
#!/usr/bin/perl
use strict;
sub myutilities {
my ($a) = @_;
print "using utilities... I am in myutilities now\n".
"and in myutilities a = $a\n\n";
}
1;
Output:
[root@dm1 ~]# ./mymain.pl
start: I am in mymain.pl
loading variables... I am in load_vars.pl now
using utilities... I am in myutilities now
and in myutilities a = apple
end: I am in mymain.pl
and n mymain the variables loaded are:
a=apple
b=banana
c=cherry
|