Wish: tree of module names

gabor on 2006-07-05T21:26:14

I would like to see a tree of all the CPAN modules in a tree-like layout

- DateTime 
    - Infinite
    ...
- Template
    - Manual
        - Refs
        - Plugins
        ...
    - Ssrvice 
Is there a script or web interface to do that?


Here's a module tree printer

brian_d_foy on 2006-07-06T01:26:31

Do you just want this script? The packages file in CPAN already has all the namespaces sorted so it's just a matter of figuring out the indention.
#!/usr/bin/perl
use strict;
 
open my $fh, "<", "/MINICPAN/modules/02packages.details.txt";
 
while ( <$fh> ) { last if /^\s*$/ } # goodbye header
 
my @Last_names;
 
while ( <$fh> ) {
    my( @names ) = split /::/, (split)[0];
 
    my $common = 0; # remove parts in common with previous module
    foreach my $i ( 0 .. $#Last_names ) {
        last unless $Last_names[$i] eq $names[$i];
        $common++;
        }
 
    foreach my $j ( $common  .. $#names ) {
        print "\t" x $common++, "- $names[$j]\n";
        }
 
    @Last_names = @names;
    }

Re:Here's a module tree printer

muttley on 2006-07-06T13:47:21

I've updated this very slightly to find your package file automatically and ungzip it. It can also take an optional root to limit the search

http://thegestalt.org/simon/perl/cpantree

Re:Here's a module tree printer

gabor on 2006-07-06T14:02:38

Thanks for both of you!

What I really would like to see is this being incorporeted to various tools such CPAN.pm and search.cpan.org (which already has something similar)