Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

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?

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2021-10-24 19:29 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (89 votes). Check out past polls.