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

Printing path to @INC

by belize (Deacon)
on May 02, 2002 at 14:26 UTC ( #163542=perlquestion: print w/replies, xml ) Need Help??

belize has asked for the wisdom of the Perl Monks concerning the following question:

Easy question:

I know that:

print "$_<BR>" for (sort keys %INC);

will print out modules in @INC, but how do I print out the paths to @INC?

Replies are listed 'Best First'.
Re: Printing path to @INC
by atopolc (Pilgrim) on May 02, 2002 at 14:31 UTC
    try:  print "$_<BR>" for (sort values %INC); instead.
Re: Printing path to @INC
by converter (Priest) on May 02, 2002 at 14:56 UTC
    print "$_<BR>" for sort @INC;

    Note: The paths listed in @INC are searched left-to-right, so it might be a good idea to leave it unsorted if you're using the output to analyze a problem with your code.

    It just occurred to me that I may have misunderstood your request. If you'd like to print both keys and values from %INC (%INC and @INC are two distinct variables), you could use:

    print "$_: $INC{$_}<BR>" for sort keys %INC;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://163542]
Approved by jlk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2019-05-22 06:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you enjoy 3D movies?



    Results (138 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!