Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Does %INC always have Unix-style paths?

by jthalhammer (Friar)
on Aug 30, 2006 at 02:59 UTC ( #570294=perlquestion: print w/replies, xml ) Need Help??
jthalhammer has asked for the wisdom of the Perl Monks concerning the following question:

Under most circumstances, the keys of %INC are the paths to the modules that have been loaded into the interpreter. I've been told that these paths are always Unix-style (i.e. forward slashes), regardless of the platform that it is actually running on. Is this true?

  • Comment on Does %INC always have Unix-style paths?

Replies are listed 'Best First'.
Re: Does %INC always have Unix-style paths?
by GrandFather (Sage) on Aug 30, 2006 at 03:13 UTC

    The key you require is "If EXPR is a bareword, the require assumes a ``.pm'' extension and replaces ``::'' with ``/'' in the filename for you, to make it easy to load standard modules. This form of loading of modules does not risk altering your namespace." (from require). See also %INC and @INC.

    Update which doesn't actually say anything about it. However:

    use lib ".\\"; print "$_\n" for @INC;


    .\ C:\Program Files\ActiveState Komodo 3.5\lib\support\dbgp\perllib C:/Perl/lib C:/Perl/site/lib .

    On an XP system and:

    print "$_ => $INC{$_}\n" for keys %INC; prints in part: IO/Socket/ => C:/Perl/lib/IO/Socket/ => C:/Perl/lib/ => C:/Perl/lib/ => C:/Perl/lib/ DB/ => C:\Program Files\ActiveState Komodo 3.5\lib +\support\dbgp\perllib/DB/

    DWIM is Perl's answer to Gödel
Re: Does %INC always have Unix-style paths?
by Anonymous Monk on Aug 31, 2006 at 07:11 UTC
    Yes, as long as you avoid writing
    $INC{q,ha\\ha\\ha\\,} = q,I'm a bad bad boy,;
    which should be written as
    $INC{q,ha/ha/ha/,} = q,I'm a bad bad boy,;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://570294]
Approved by chargrill
[marto]: it should just be a script, pp, or on windows pp.bat, post install you should just be able to call pp -x packed.exe as the PPM package should put everything required into the appropriate path
[marto]: ah, some time ago pp became it's own package, try searching your repo for PAR::Packer
[marto]: again, Strawberry + cpanm for the win: cpanm pp to install

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2018-01-19 14:19 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (218 votes). Check out past polls.