Hi, Experts,
I wrote a few simple sample codes in a hierarchy shown below:
I can only run callingModuleFromSubLevel.pl under subdir1:
However, neither callingModuleFromTopLevel.pl nor callingModuleFromSubLevel.pl can be invoked at the top level:
How to fix these two problems?
Thanks.
I wrote a few simple sample codes in a hierarchy shown below:
Code:
[b]% ls *[/b]
callingModuleFromTopLevel.pl*
subdir1:
callingModuleFromSubLevel.pl* subLevelModule_1.pm*
subdir2:
subLevelModule_2.pm*
[b]% cat callingModuleFromTopLevel.pl[/b]
use lib "./subdir1";
use subLevelModule_1;
print "$0. In top level. Calling subLevelModule_1::func1().\n";
&subLevelModule_1::func1;
[b]% cat subdir1/callingModuleFromSubLevel.pl[/b]
use subLevelModule_1;
print "$0, In subdir1. Calling subLevelModule_1::func1().\n";
&subLevelModule_1::func1;
[b]% cat subdir1/subLevelModule_1.pm[/b]
package subLevelModule_1;
use lib "../subdir2";
use subLevelModule_2;
sub func1 {
my $str = "subLevelModule_1.pm..func1() is called.";
print "$str\n";
print "subLevelModule_1.pm..func1() is calling ../subdir2/subLevelModule_2::func2()\n";
&subLevelModule_2::func2;
}
1;
[b]% cat subdir2/subLevelModule_2.pm[/b]
package subLevelModule_2;
sub func2 {
my $str = "subLevelModule_2.pm..func2() is called.";
print "$str\n";
}
1;
I can only run callingModuleFromSubLevel.pl under subdir1:
Code:
[b]% perl callingModuleFromSubLevel.pl[/b]
callingModuleFromSubLevel.pl, In subdir1. Calling subLevelModule_1::func1().
subLevelModule_1.pm..func1() is called.
subLevelModule_1.pm..func1() is calling ../subdir2/subLevelModule_2::func2()
subLevelModule_2.pm..func2() is called.
However, neither callingModuleFromTopLevel.pl nor callingModuleFromSubLevel.pl can be invoked at the top level:
Code:
[b]% perl callingModuleFromTopLevel.pl[/b]
Can't locate [b][COLOR=red]subLevelModule_2.pm[/color][/b] in @INC (@INC contains: ../subdir2 ./subdir1 /usr/perl5/5.8.4/lib/sun4-solaris-64int /usr/perl5/5.8.4/lib /usr/perl5/site_perl/5.8.4/sun4-solaris-64int /usr/perl5/site_perl/5.8.4 /usr/perl5/site_perl /usr/perl5/vendor_perl/5.8.4/sun4-solaris-64int /usr/perl5/vendor_perl/5.8.4 /usr/perl5/vendor_perl .) at subdir1/subLevelModule_1.pm line 3.
BEGIN failed--compilation aborted at subdir1/subLevelModule_1.pm line 3.
Compilation failed in require at callingModuleFromTopLevel.pl line 2.
BEGIN failed--compilation aborted at callingModuleFromTopLevel.pl line 2.
[b]% perl subdir1/callingModuleFromSubLevel.pl[/b]
Can't locate [b][COLOR=red]subLevelModule_1.pm[/color][/b] in @INC (@INC contains: /usr/perl5/5.8.4/lib/sun4-solaris-64int /usr/perl5/5.8.4/lib /usr/perl5/site_perl/5.8.4/sun4-solaris-64int /usr/perl5/site_perl/5.8.4 /usr/perl5/site_perl /usr/perl5/vendor_perl/5.8.4/sun4-solaris-64int /usr/perl5/vendor_perl/5.8.4 /usr/perl5/vendor_perl .) at subdir1/callingModuleFromSubLevel.pl line 1.
BEGIN failed--compilation aborted at subdir1/callingModuleFromSubLevel.pl line 1.
How to fix these two problems?
Thanks.