How does perl know it's environment.

Discussion in 'Perl Misc' started by TLOlczyk, Jul 12, 2004.

  1. TLOlczyk

    TLOlczyk Guest

    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.
    Especially in a custom build where the locationsd are in
    nontradfitional packages.


    The reply-to email address is .
    This is an address I ignore.
    To reply via email, remove 2002 and change yahoo to
    interaccess,

    **
    Thaddeus L. Olczyk, PhD

    There is a difference between
    *thinking* you know something,
    and *knowing* you know something.
     
    TLOlczyk, Jul 12, 2004
    #1
    1. Advertising

  2. TLOlczyk <> wrote in
    news::

    > 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.


    perl -V

    --
    A. Sinan Unur
    d
    (remove '.invalid' and reverse each component for email address)
     
    A. Sinan Unur, Jul 12, 2004
    #2
    1. Advertising

  3. TLOlczyk

    TLOlczyk Guest

    On 12 Jul 2004 20:51:10 GMT, "A. Sinan Unur"
    <> wrote:

    >TLOlczyk <> wrote in
    >news::
    >
    >> 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.

    >
    >perl -V


    I did not ask how i find out these things. I asked how perl knows it.



    The reply-to email address is .
    This is an address I ignore.
    To reply via email, remove 2002 and change yahoo to
    interaccess,

    **
    Thaddeus L. Olczyk, PhD

    There is a difference between
    *thinking* you know something,
    and *knowing* you know something.
     
    TLOlczyk, Jul 12, 2004
    #3
  4. TLOlczyk <> wrote in
    news::

    > On 12 Jul 2004 20:51:10 GMT, "A. Sinan Unur"
    > <> wrote:
    >
    >>TLOlczyk <> wrote in
    >>news::
    >>
    >>> 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.

    >>
    >>perl -V

    >
    > I did not ask how i find out these things. I asked how perl knows it.


    I understand and perl -V is the answer.

    That information is set at build time (or installation time on Win32).

    perl -help

    -V[:variable] print configuration summary (or a single Config.pm
    variable)

    --
    A. Sinan Unur
    d
    (remove '.invalid' and reverse each component for email address)
     
    A. Sinan Unur, Jul 12, 2004
    #4
  5. TLOlczyk <> wrote:

    > 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. Especially in a custom build where the locationsd are in
    > nontradfitional packages.


    The paths are compiled into the perl binary. They are specified
    when perl is built.

    Peter

    --
    #!/local/bin/perl5 -wp -*- mode: cperl; coding: iso-8859-1; -*-
    # matlab comment stripper (strips comments from Matlab m-files)
    s/^((?:(?:[])}\w.]'+|[^'%])+|'[^'\n]*(?:''[^'\n]*)*')*).*/$1/x;
     
    Peter J. Acklam, Jul 12, 2004
    #5
  6. Peter J. Acklam <> wrote:
    > TLOlczyk <> wrote:
    >
    >> 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. Especially in a custom build where the locationsd are in
    >> nontradfitional packages.

    >
    > The paths are compiled into the perl binary. They are specified
    > when perl is built.



    and

    perl -V

    will show them to you.


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Jul 12, 2004
    #6
  7. (Peter J. Acklam) writes:

    > TLOlczyk <> wrote:
    >
    > > 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. Especially in a custom build where the locationsd are in
    > > nontradfitional packages.

    >
    > The paths are compiled into the perl binary. They are specified
    > when perl is built.


    This is true but on Win32 they can also be specified in the registry
    (see perlwin32)

    --
    \\ ( )
    . _\\__[oo
    .__/ \\ /\@
    . l___\\
    # ll l\\
    ###LL LL\\
     
    Brian McCauley, Jul 12, 2004
    #7
  8. On Mon, 12 Jul 2004 15:43:27 -0500, TLOlczyk 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

    ^^^^^^^^^^^

    It's "environment", not "environmental. They are not "green" ... as
    someone pointed out to me in this group :)

    Jim
     
    James Willmore, Jul 13, 2004
    #8
  9. Tad McClellan <> wrote:

    > Peter J. Acklam <> wrote:
    >
    > > TLOlczyk <> wrote:
    > >
    > > > 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. Especially in a custom build where the
    > > > locationsd are in nontradfitional packages.

    > >
    > > The paths are compiled into the perl binary. They are
    > > specified when perl is built.

    >
    > and
    >
    > perl -V
    >
    > will show them to you.


    That reply has been given numerous times already, but it only
    shows which paths perl knows about and not *how* perl knows about
    them, which was the question here.

    Peter

    --
    #!/local/bin/perl5 -wp -*- mode: cperl; coding: iso-8859-1; -*-
    # matlab comment stripper (strips comments from Matlab m-files)
    s/^((?:(?:[])}\w.]'+|[^'%])+|'[^'\n]*(?:''[^'\n]*)*')*).*/$1/x;
     
    Peter J. Acklam, Jul 13, 2004
    #9
  10. TLOlczyk

    Tintin Guest

    "TLOlczyk" <> wrote in message
    news:...

    >Subject: How does perl know it's environment


    How does perl know it is environment? No idea. Perhaps you meant, how does
    Perl know its environment.

    >
    > The reply-to email address is .
    > This is an address I ignore.
    > To reply via email, remove 2002 and change yahoo to
    > interaccess,


    Post here, reply here, read here.
     
    Tintin, Jul 14, 2004
    #10
  11. Tintin wrote:

    > How does perl know it is environment? No idea. Perhaps you meant, how
    > does Perl know its environment.


    Well, since we're going to nit-pick...

    The OP's usage was correct. The question was about "perl" - i.e. the Perl
    interpreter often found in /usr/bin. It was not about "Perl" - i.e. the
    language that "perl" is designed to execute.

    sherm--

    --
    Cocoa programming in Perl: http://camelbones.sourceforge.net
    Hire me! My resume: http://www.dot-app.org
     
    Sherm Pendley, Jul 14, 2004
    #11
  12. TLOlczyk

    Paul Lalli Guest

    On Wed, 14 Jul 2004, Sherm Pendley wrote:

    > Tintin wrote:
    >
    > > How does perl know it is environment? No idea. Perhaps you meant, how
    > > does Perl know its environment.

    >
    > Well, since we're going to nit-pick...
    >
    > The OP's usage was correct. The question was about "perl" - i.e. the Perl
    > interpreter often found in /usr/bin. It was not about "Perl" - i.e. the
    > language that "perl" is designed to execute.


    I was going to post that too, until I realized Tintin was nitpicking about
    "it's" vs "its". Which, in a Perl newsgroup, is far worse than nitpicking
    about Perl vs perl.

    Paul Lalli
     
    Paul Lalli, Jul 14, 2004
    #12
  13. Paul Lalli wrote:

    > I was going to post that too, until I realized Tintin was nitpicking about
    > "it's" vs "its". Which, in a Perl newsgroup, is far worse than nitpicking
    > about Perl vs perl.


    Why is that worse? He used a single-quote. ;-)

    sherm--

    --
    Cocoa programming in Perl: http://camelbones.sourceforge.net
    Hire me! My resume: http://www.dot-app.org
     
    Sherm Pendley, Jul 14, 2004
    #13
  14. TLOlczyk

    Tintin Guest

    "Sherm Pendley" <> wrote in message
    news:...
    > Tintin wrote:
    >
    > > How does perl know it is environment? No idea. Perhaps you meant, how
    > > does Perl know its environment.

    >
    > Well, since we're going to nit-pick...
    >
    > The OP's usage was correct. The question was about "perl" - i.e. the Perl
    > interpreter often found in /usr/bin. It was not about "Perl" - i.e. the
    > language that "perl" is designed to execute.


    Touche!
     
    Tintin, Jul 14, 2004
    #14
  15. In article <>, Sherm Pendley wrote:
    > Paul Lalli wrote:
    >
    >> I was going to post that too, until I realized Tintin was nitpicking about
    >> "it's" vs "its". Which, in a Perl newsgroup, is far worse than nitpicking
    >> about Perl vs perl.

    >
    > Why is that worse? He used a single-quote. ;-)


    Actually, no he did't :)

    > > How does perl know it is environment? No idea. Perhaps you meant, how

    ^^^^^

    Kevin
     
    Kevin Collins, Jul 14, 2004
    #15
  16. TLOlczyk

    Alan Stewart Guest

    On Mon, 12 Jul 2004 15:43:27 -0500, TLOlczyk <>
    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.
    >Especially in a custom build where the locationsd are in
    >nontradfitional packages.
    >
    >
    >The reply-to email address is .
    >This is an address I ignore.
    >To reply via email, remove 2002 and change yahoo to
    >interaccess,
    >
    >**
    >Thaddeus L. Olczyk, PhD
    >
    >There is a difference between
    >*thinking* you know something,
    >and *knowing* you know something.


    Since this thread seems to have offered mostly English lessons or
    mis-information, I'll offer an answer.

    perl knows the path it executed from, uses that to get the lib path,
    and gets its configuration from lib/Config.pm.

    It doesn't have paths built into the binary and it doesn't use the
    Win32 registry.

    Try renaming Config.pm and doing "perl -V". See what you get.

    Or copy perl.exe and the perlxx.dll to another directory, and do
    "perl-V" from there (or copy perl and the perl lib if running *nix -
    you didn't say what OS). Same result.

    HTH
    Alan
     
    Alan Stewart, Jul 15, 2004
    #16
  17. Alan Stewart <> wrote:
    > On Mon, 12 Jul 2004 15:43:27 -0500, TLOlczyk <>
    > 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.
    >>Especially in a custom build where the locationsd are in
    >>nontradfitional packages.
    >>
    >>
    >>The reply-to email address is .
    >>This is an address I ignore.
    >>To reply via email, remove 2002 and change yahoo to
    >>interaccess,
    >>
    >>**
    >>Thaddeus L. Olczyk, PhD
    >>
    >>There is a difference between
    >>*thinking* you know something,
    >>and *knowing* you know something.

    >
    > Since this thread seems to have offered mostly English lessons or
    > mis-information, I'll offer an answer.
    >
    > perl knows the path it executed from, uses that to get the lib path,
    > and gets its configuration from lib/Config.pm.
    >


    No not true.

    > It doesn't have paths built into the binary and it doesn't use the
    > Win32 registry.
    >
    > Try renaming Config.pm and doing "perl -V". See what you get.
    >


    Try however doing:

    perl -e'print "@INC"';

    this works fine with the Config.pm there or not.

    Yes it does use Config.pm to provide the information with -V but the
    @INC isn't part of that, it just fails before it gets to print the @INC
    if the Config.pm isn't there.

    /J\
     
    Jonathan Stowe, Jul 15, 2004
    #17
  18. TLOlczyk

    Juha Laiho Guest

    Alan Stewart <> said:
    >On Mon, 12 Jul 2004 15:43:27 -0500, TLOlczyk <>
    >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)

    Further, a search through the above shared library file finds:
    /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; 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).
    --
    Wolf a.k.a. Juha Laiho Espoo, Finland
    (GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
    PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
    "...cancel my subscription to the resurrection!" (Jim Morrison)
     
    Juha Laiho, Jul 15, 2004
    #18
  19. TLOlczyk

    Alan Stewart Guest

    On Thu, 15 Jul 2004 10:05:54 GMT, Jonathan Stowe <>
    wrote:

    >Alan Stewart <> wrote:
    >> On Mon, 12 Jul 2004 15:43:27 -0500, TLOlczyk <>
    >> 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.
    >>>Especially in a custom build where the locationsd are in
    >>>nontradfitional packages.
    >>>
    >>>
    >>>The reply-to email address is .
    >>>This is an address I ignore.
    >>>To reply via email, remove 2002 and change yahoo to
    >>>interaccess,
    >>>
    >>>**
    >>>Thaddeus L. Olczyk, PhD
    >>>
    >>>There is a difference between
    >>>*thinking* you know something,
    >>>and *knowing* you know something.

    >>
    >> Since this thread seems to have offered mostly English lessons or
    >> mis-information, I'll offer an answer.
    >>
    >> perl knows the path it executed from, uses that to get the lib path,
    >> and gets its configuration from lib/Config.pm.
    >>

    >
    >No not true.
    >
    >> It doesn't have paths built into the binary and it doesn't use the
    >> Win32 registry.
    >>
    >> Try renaming Config.pm and doing "perl -V". See what you get.
    >>

    >
    >Try however doing:
    >
    > perl -e'print "@INC"';
    >
    >this works fine with the Config.pm there or not.
    >
    >Yes it does use Config.pm to provide the information with -V but the
    >@INC isn't part of that, it just fails before it gets to print the @INC
    >if the Config.pm isn't there.
    >
    >/J\


    Well, I might be completely wrong on Unix (I don't have a Unix box to
    try), but on my Win XP machine I did this:

    C:\test>copy \perl\bin\perl.exe
    1 file(s) copied.

    C:\test>perl -e "print @INC;"
    c:/Perl/libc:/Perl/site/lib.
    C:\test>copy \perl\bin\perl58.dll
    1 file(s) copied.

    C:\test>perl -e "print @INC;"
     
    Alan Stewart, Jul 16, 2004
    #19
  20. TLOlczyk

    TLOlczyk Guest

    On Thu, 15 Jul 2004 19:33:11 -0700, Alan Stewart <>
    wrote:

    >>> It doesn't have paths built into the binary and it doesn't use the
    >>> Win32 registry.
    >>>
    >>> Try renaming Config.pm and doing "perl -V". See what you get.
    >>>

    >>
    >>Try however doing:
    >>
    >> perl -e'print "@INC"';
    >>
    >>this works fine with the Config.pm there or not.
    >>
    >>Yes it does use Config.pm to provide the information with -V but the
    >>@INC isn't part of that, it just fails before it gets to print the @INC
    >>if the Config.pm isn't there.
    >>
    >>/J\

    >
    >Well, I might be completely wrong on Unix (I don't have a Unix box to
    >try),

    I find it hard to believe that perl has that information built in.
    More likely it has some mechaqnism to find out where.

    Consider the following example:
    Popfile ( for those not already familiar with it ) is a spam filter
    written in perl. People download and install it on their machines.
    perl comes with it. There are lots of programs which behave the same
    way.

    Now given that, you have a perl which installs itself someplace on
    your machine. Maybe it's f:/email/programs/popfile, or c:/windows
    or d:/programs or ... . Instead a different version may install itself
    on UNIX. Perhaps in /usr/local/bin or /usr/popfile of
    /home/myaccount/email or /home//hisaccount.

    The point is that this precompiled version of perl installs itself in
    a random location *and works*. If environment were precompiled
    into the binary, then this could not possibly be the case. So it is
    definitely not compiled into the binary.




    The reply-to email address is .
    This is an address I ignore.
    To reply via email, remove 2002 and change yahoo to
    interaccess,

    **
    Thaddeus L. Olczyk, PhD

    There is a difference between
    *thinking* you know something,
    and *knowing* you know something.
     
    TLOlczyk, Jul 16, 2004
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DP
    Replies:
    0
    Views:
    1,185
  2. Rahul S.
    Replies:
    1
    Views:
    315
    Joona I Palaste
    Oct 26, 2004
  3. Replies:
    5
    Views:
    702
  4. Simon Egginton

    LOOK! i just want to know does anyone know...

    Simon Egginton, Jul 26, 2004, in forum: Javascript
    Replies:
    3
    Views:
    200
    Dr John Stockton
    Jul 26, 2004
  5. Andries

    I know, I know, I don't know

    Andries, Apr 23, 2004, in forum: Perl Misc
    Replies:
    3
    Views:
    283
    Gregory Toomey
    Apr 23, 2004
Loading...

Share This Page