I have all of the modules that I have created either in the same single directory that contains the scripts or in sub-directories of the script directory. I use this in every script:
use FindBin qw($Bin); use lib $Bin; I never have any problems no matter where the script is executed from. Hope this helps. Dirk Bremer - Senior Systems Engineer - ESS/AMS - NISC Lake St. Louis MO - USA Central Time Zone 636-755-2652 fax 636-755-2503 [EMAIL PROTECTED] www.nisc.coop > Yes, I will have to calculate the path, since it is not absolute. > > If I put a relative path in @INC, I guess it would be relative to the > current directory. Which is whatever the directory the console is in > when it runs the script. Not very useful for finding > modules. Instead > I want to find a path relative to where the script is located. > (Actually, I'm interested in finding the parent directory of the one > where the script is located.) As far as I can tell, there is no > function that tells me that. That is why I have to calculate it. > > I suppose putting the path determination stuff in a function, and > putting a pointer to that in @INC would work. I guess I just felt > skiddish about it because it seems unusual. > > What is the most common way that people handle this? That > is, say your > modules are in the same folder as the main script. (Which I > would think > would be the most common case, except for CPAN or PPM modules.) Do > people usually write a function to determine where the script is > located? You'd think there would be a common function for this.... > > My code currently handles it is below, which seems incredibly obtuse, > but I couldn't figure a simpler reliable way. That is the > code I'd have > to pass in as a function to @INC (except with 'return' > instead of 'chdir'). > > #---- determine V-ASC installation directory > ------------------------------- > #-- it is the parent directory of where this file is run from > > my ($VAscVolume,$ServerPath) = > File::Spec->splitpath(File::Spec->rel2abs($0)); > my @ServerDirs = File::Spec->splitdir($ServerPath); > my $VAscPath = File::Spec->catdir(@[EMAIL PROTECTED]); > my $VAscInstallDir > = > File::Spec->canonpath(File::Spec->catpath($VAscVolume,$VAscPath,'')); > my $VAscServerDir > = > File::Spec->canonpath(File::Spec->catpath($VAscVolume,$ServerP > ath,'')); > > chdir $VAscInstallDir; > > -- > Lyle Kopnicky > Software Project Engineer > Veicon Technology, Inc. _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs