On Tuesday, Nov 11, 2003, at 13:12 US/Pacific, Raj (Basavaraj) Karadakal wrote:
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.
there are three basic ideas you might want to consider
a. have your modules install into the classic CPAN section
site_perl
and that can be done with the standard perl installation tricks that you can learn about with 'perldoc h2xs' and going through that process. In the long run this will be more useful for you as you will be able to include OS specific XS extensions as you find that useful. This also allows you to write code that will expect that the modules are merely installed 'the cpan way' and hence will not have to start with the
use lib <some_off_set>; use Foo::Bar;
b. if you want to keep the simple 'tarball installer' then think about laying out the modules in the form
./lib/<modules_here>
thus all of the perl code will need to know
use lib "./lib";
thus if your code wants to use the Foo::Bar module it already will be looking for it at
./lib/Foo/Bar.pm
which will suffice for the near term solution.
c. Remember that PUSHING things into @INC is a really unpleasant way of trying to deal with solving the problem - even more ungainly since you are also apparently confusing things that need to be done at 'compile time' with things that are run time issues.
what you want IS NOT an open file handle, but the 'path element' that is the top of where to find the modules - which can be the relative offset as noted above in that use lib approach.
you really will want to get Schwartz's new book on Perl Modules, Refs, objects.
Also go back over
perldoc perlmod perldoc perlmodlib perldoc perlmodinstall
these may help you simplify your life.
ciao drieux
---
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]