http://www.perlmonks.org?node_id=163542

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;