develooper Front page | perl.perl5.porters | Postings from May 2008

[perl #37260] [DOC-PATCH] perlfaq3: Installed modules (File::Find, option follow) (was: A fix to a bug of sample code for finding modules in perlfaq3.pod)

Thread Next
From:
Bram via RT
Date:
May 25, 2008 02:23
Subject:
[perl #37260] [DOC-PATCH] perlfaq3: Installed modules (File::Find, option follow) (was: A fix to a bug of sample code for finding modules in perlfaq3.pod)
Message ID:
rt-3.6.HEAD-11257-1211668679-1899.37260-14-0@perl.org
On Fri Sep 23 22:14:24 2005, tarok@acm.org wrote:

> 
> perlfaq3.pod document in the core Perl package has a section
> 	"How do I find which modules are installed on my system?"
> where it gives a sample code to list available Perl modules on the
>    system.
> 
> I found the sample code
> 
> 	use File::Find::Rule;
> 	my @files = File::Find::Rule->file()->name( '*.pm' )->in( @INC
 );
> 
> and
> 
>     use File::Find;
>     my @files;
>     find sub { push @files, $File::Find::name if -f _ && /\.pm$/ },
>          @INC;
> 	print join "\n", @files;
> 
> don't give a complete result on UNIX systems in case a directory path
>    in @INC is a symbolic link and doesn't have the corresponding
>    actual directory in @INC.
> 
> For example on my Debian system @INC is set to
> ('/etc/perl' '/usr/local/lib/perl/5.8.7' '/usr/local/share/perl/
5.8.7'
>    '/usr/lib/perl5' '/usr/share/perl5' '/usr/lib/perl/5.8'
>    '/usr/share/perl/5.8' '/usr/local/lib/site_perl' '.')
> and '/usr/lib/perl/5.8' is a symbolic link to '/usr/lib/perl/5.8.7'.
> Then the code will never list modules in '/usr/lib/perl/5.8' nor
>    '/usr/lib/perl/5.8.7',
> because File::Find::find doesn't work on a symlink directory unless
>    the follow option is enabled.
> 
> Giving the follow option will slow the processing if @INC includes
>    '/usr/lib/perl/5.8.7' too,
> so I think it would be better to change @INC to include only actual
>    directories before passing to find.
> 

Patch that adds follow => 1 in the examples of File::Find attached.
(Also changed in the patch is the identation of the code, so that it 
is the same as the other examples)


Kind regards,

Bram

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