Re: How does perl know it's environment.

From: Alan Stewart (astewart1_at_cox.net)
Date: 07/16/04


Date: Fri, 16 Jul 2004 00:40:36 -0700

On Thu, 15 Jul 2004 13:22:02 GMT, Juha Laiho <Juha.Laiho@iki.fi>
wrote:

>Alan Stewart <astewart1@cox.net> said:
>>On Mon, 12 Jul 2004 15:43:27 -0500, TLOlczyk <olczyk2002@yahoo.com>
>>wrote:
>>>I've scoured the documentation and have not been able to find
>>>an an answer to the following question.
>>>
>>>Assuming there are no environmental variables set specifically
>>>for perl. How does perl know where to find it's installed
>>>packages, where to install packages, location of the library etc.
>...
>>Since this thread seems to have offered mostly English lessons or
>>mis-information, I'll offer an answer.
>
>But yet another false one - on Unix, at least.
>
>>It doesn't have paths built into the binary and it doesn't use the
>>Win32 registry.
>
>"ldd /usr/bin/perl" gives:
> libperl.so => /usr/lib/perl5/5.8.0/i386-linux-thread-multi/CORE/libperl.so (0x40017000)
>(among other libraries -- and no, that path doesn't change just by copying
>/usr/bin/perl somewhere else; it's hardcoded into the binary)

I assume that if you just copied /usr/bin/perl somewhere, that it
found libperl.so in LD_LIBRARY_PATH, not from something built into
/usr/bin/perl

What I suggested was copying both /usr/bin/perl AND libperl.so
somwhere. And you probably need to change LD_LIBRARY_PATH to point
there temporarily to do that. In Windows, I just let it find the lib
in "." first without modifying PATH.

I don't have Unix, so I don't know if it's true there or not. I am
just inferring from reading the doc on ldd. What do you see if you
move both and try "perl -V"?

>
>Further, a search through the above shared library file finds:

What kind of search?

>/usr/lib/perl5/5.8.0
>/usr/lib/perl5/site_perl
>/usr/lib/perl5/vendor_perl
>/usr/lib/perl5/5.8.0/i386-linux-thread-multi
>/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
>/usr/lib/perl5/site_perl/5.8.0
>/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
>/usr/lib/perl5/vendor_perl/5.8.0
>
>... which very much looks like the initial @INC contents.
>
>In Windows it could well be that some locations can be determined by
>the installation location of the actual binary file;

See the example in my reply to Jonathan. At least Windows can. I
always assume that Unix can do at least as much :)

> in Unix side it's
>pretty much impossible to even find out where the "currently running"
>executable is located in the directory hierarchy (especially given the
>facts that a single file may have multiple directory entries in various
>places across the directory structure, and that the file might not have
>_any_ directory entry by the time it tries to determine from where it was
>run).

I would expect the OS knows which of many possible paths it used to
fetch an executable file, even if it is not readily determined by an
application programmer. Again, I am only inferring from the Windows
example. A perl program may get misleading info as to the path of the
perl script, but Windows certainly knows where the perlxx.dll came
from and that is available inside the dll code.

Alan



Relevant Pages

  • Re: Unix commands
    ... I don't recall ever writing a program that needed to trawl through ... All the Perl programs ... I'm not going to worry whether my tool is going to be run on Windows. ... // Actually many times I've ported my programs and tools to Unix too! ...
    (comp.lang.perl.misc)
  • Re: Unix commands
    ... ==> writing the program in Perl, ... ==> program that had to be ported to Windows. ... After installing a Unix toolkit the script ... And every other common Unix tool. ...
    (comp.lang.perl.misc)
  • Re: Perl versus other scripting language
    ... I don't see this as a disadvantage. ... but there are more perl modules that don't work at all under ... Windows, or that work badly, or which work with a version of perl but don't ... Unix manpages (a lovely thing if you work under Windows with no ...
    (perl.beginners)
  • Re: How do Unix grep, find, sort?
    ... "noleander" wrote in message ... > reading the replies above I've settled on Perl. ... > just about any function a Unix relic would need. ... I'm new to Windows, after programming for 20 years in Unix. ...
    (microsoft.public.windows.server.scripting)
  • Re: What is the more popular UNIX flavor?
    ... about my experience with Solaris and Cygwin. ... installing packages. ... needing eg tftp you only need to activate on a Unix system. ... probably need installing first on the equivalent Windows system. ...
    (comp.unix.questions)