Hi, I am trying to package a perl script and the modules it uses , in a tar file. When untarred on any machine, the modules can be found in a known relative path with respect to the script. The path in which these modules are available can change depending on where the package got untarred. So only way the script can find modules is by using relative path in @INC. But for this to work the user should always be in the same directory as the script. To overcome this limitation of my script, I am trying to use a reference to a subroutine in @INC, which returns the filehandle to the module. When I run my script, I am able to find the module and open it, and return the filehandle, but the perl still complains that it cannot find the module.
$/tmp/1.pl Found /tmp/usr/mods/setuprhost.pm Can't locate setuprhost.pm in @INC (@INC contains: /usr/local/lib/perl5/5.6.1/sun4-solaris /usr/local/lib/perl5/5.6.1 /usr/local/lib/perl5/site_perl/5.6.1/sun4-solaris /usr/local/lib/perl5/site_perl/5.6.1 /usr/local/lib/perl5/site_perl . CODE(0xfeda0)) at /home/users/bkaradak/tmp/install_card line 33. BEGIN failed--compilation aborted at /home/users/bkaradak/tmp/install_card line 33. Following is my script:- #!/usr/local/bin/perl -w sub readMod { my ($ref,$mod) = @_; my $dir = $0; my $modPath; $dir =~ s/\/[^\/]+$//; if ( -f "$dir/usr/mods/$mod" ) { $modPath = "$dir/usr/mods/$mod"; } if ( -f "$modPath" ) { print "Found $modPath\n"; open (MOD,"$modPath") or die "Cannot open $modPath $!\n"; return MOD ; }else { return undef ; } } BEGIN { push ( @INC, \&readMod ); } use setuprhost; &setuprhost::Setup(<host name>); What am I doing wrong? TIA -Basavaraj -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]