in reply to Re: How to list all the installed perl modules
in thread How to list all the installed perl modules

I think this code would not find Modules in Subdirectories, e.g. Net::Telnet, so I'd prefer using something like the following:
use File::Find; # Module list foreach my $dir (@INC){ find sub { print "$File::Find::name\t" if /\.pm$/; }, $dir; }
or shorter:
use File::Find; find sub { print "$File::Find::name\t" if /\.pm$/; }, @INC;

Replies are listed 'Best First'.
Re: Re: Re: How to list all the installed perl modules
by fuzzyping (Chaplain) on Mar 18, 2002 at 00:56 UTC
    Yeah, I realized that shortly thereafter. I've been picking my brain trying to figure out a way to do this with native functions, but I can't scale the recursion. Anyone else have any ideas? I've tried checking the input for (-d) and pushing it back to @INC, but my "while" doesn't seem to honor this attempt...
    perl -e 'while (<@INC>) { while (<$_/**>) { if (-d) { push(@INC,$_) } +elsif (/\.pm/) { print "$_\n" } else { next } } }'

    -fuzzyping

      how about

      perl -e 'sub f{$d=pop;/\.pm/&&-f$_&&print"$_\n";-d$_&&f($_)for(<$d/*>) +}f($_)for@INC'
      while(<@INC>)
      Is very suspect code.... You probably want something like:
      my @copy = @INC; while(defined($_ = shift(@copy))) { # push to @copy as necessary }
      See Why is @array so slow? for more details.

      -Blake