develooper Front page | perl.perl5.porters | Postings from July 2003

Moving $Config{scriptdirexp} to the end of the perldoc search list

Thread Next
From:
Michael G Schwern
Date:
July 30, 2003 23:18
Subject:
Moving $Config{scriptdirexp} to the end of the perldoc search list
Message ID:
20030731061813.GB24299@windhund.schwern.org
I got a surprising result with perldoc on OS X just now:

"perldoc CPAN" brought up...

CPAN(1)        User Contributed Perl Documentation        CPAN(1)

NAME
       cpan - easily interact with CPAN from the command line

SYNOPSIS
               # with arguments, installs specified modules
               cpan module_name [ module_name ... ]

"perldoc -l CPAN" and "perldoc -m CPAN" showed that perldoc found
/usr/bin/cpan instead of CPAN.pm.  This is perldoc 3.08 and 3.09.

This surprising result is because perldoc, before checking @INC, checks 
$Config{scriptdirexp}.  A feature I'd never realized it had, but it seems
to have been doing this for a while.  Coupled with my case-insensitive 
filesystem it caused it to pick up /usr/bin/cpan before the CPAN.pm module.

I'd argue that perldoc should err on the side of modules over scripts.
The following patch moves $Config{scriptdirexp} to the end of perldoc's
search path.

--- lib/Pod/Perldoc.pm	2003/07/31 05:49:57	1.1
+++ lib/Pod/Perldoc.pm	2003/07/31 05:50:01
@@ -698,7 +698,7 @@
         # We must look both in @INC for library modules and in $bindir
         # for executables, like h2xs or perldoc itself.
 
-        my @searchdirs = ($self->{'bindir'}, @INC);
+        my @searchdirs = (@INC, $self->{'bindir'});
         unless ($self->opt_m) {
             if (IS_VMS) {
                 my($i,$trn);



-- 
Stupid am I?  Stupid like a fox!

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About