On Tue, Nov 11, 2003 at 04:12:03PM -0500, 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.
I'd usually use FindBin for this. The [EMAIL PROTECTED] are definitely cool, but you really don't need them here. use FindBin qw($Bin); # warts and all use lib "$Bin/lib"; use YourModule; > 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. > > if ( -f "$modPath" ) { > print "Found $modPath\n"; > open (MOD,"$modPath") or die "Cannot open $modPath $!\n"; > return MOD ; > }else { > return undef ; > } That said, you could just return \*MOD and it would work (or use the newish lexical filehandles). use strict; # always! use lib sub { my $file = uc $_[1]; # Foo.pm => FOO.PM open my $fh, $file; # returning undef is ok return $fh; }; -- Steve -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]