Chris Wagner wrote:

At 11:13 AM 1/12/2006 -0800, Lyle Kopnicky wrote:
  * use() requires that you use a bareword for the module name (might
    be nice, if I could solve the @INC path problem)

I don't know why u think u have a @INC problem.  There's lots of ways to do
it.  use lib "path", push @INC, path, perl -Ipath.  U can even put an
anonymous routine directly in @INC that will be evaluated to come up with
the approriate path.
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,$ServerPath,''));

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

Reply via email to