Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: standard library to return system paths

by syphilis (Archbishop)
on Jun 08, 2016 at 13:47 UTC ( [id://1165144]=note: print w/replies, xml ) Need Help??


in reply to standard library to return system paths

Running this code on 2 OSes, gave me the following results, so far: Lin: /etc/perl Win: C:/Perl/site/lib


This is really puzzling.
Are you claiming that you've located a Windows perl whose @INC consists only of C:/Perl/site/lib (and perhaps also .) ?

I've not yet encountered a Windows perl whose @INC included C:/Perl/site/lib but did not also include C:/Perl/lib

I've read every post in this thread and I still struggle to understand what you are seeking.

UPDATE: Hang on ... the code you claimed to have run is:
for(@INC){ unless($_ eq '.'){ $libPath = $_; last; } }
but I think you probably wanted:
for(@INC){ unless($_ eq '.'){ $libPath .= "$_ "; } }
Does that alteration lead to the (expected) inclusion of C:/Perl/lib on the Windows system ?

I'm assuming that you really want the entire @INC, ignoring the "." ... in which case you might just as well
print "@INC\n";
and mentally ignore the dot.

Cheers,
Rob

Replies are listed 'Best First'.
Re^2: standard library to return system paths
by igoryonya (Pilgrim) on Jul 11, 2016 at 22:11 UTC
    Are you claiming that you've located a Windows perl whose @INC consists only of C:/Perl/site/lib (and perhaps also .) ?
    No, I am claming, that on windows, I find such path. I've never said, that that's the only path, I find.
    I've read every post in this thread and I still struggle to understand what you are seeking.
    I don't know, how much more clearly to explain, which I did several times and in different formulations.
    How much more clearly I need to describe, that I need my programs to know system (independently of OS) paths with the least amount of code added to every program.
    They need to know system common library paths, systemwide config paths, program/bin, etc., so my code was correct.
    How do you think I would use the whole string of paths to get the final file?
    From your code, I'd get:
    "/etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /us +r/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 +/usr/local/lib/site_perl "
    How do you think, it would be useful? How do you think, I would locate a final file with such a path?
    If I would really need such a result, there is a better and shorter way to do it:
    $libPath = join(" ", grep { $_ ne "." } @INC);
    How do you think, I would put my libraries, finding system paths in this, "found" path? How would I do, even a simple thing, such as (with the resulted path from your suggested code)?:
    &cp($file2Copy, "$libPath/$file2Copy");
    No, I only need one (possibly, first found) path to place the common file to, and nothing is expected, that's why I need a way to determine the path. If I would "expect" some path, as you say, I would just use it, since, it would be on all systems, as "expected".
    print "@INC\n";
    And how do you think, this would be useful?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1165144]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-25 23:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found