http://qs321.pair.com?node_id=869107

astroboy has asked for the wisdom of the Perl Monks concerning the following question:

Rather than wanting to know what other CPAN modules a particular CPAN module needs, I want to know the reverse: given a CPAN module, what other modules use it?. I'm primarily interested in looking at code to see how particular modules are being used as a learning exercise.

Replies are listed 'Best First'.
Re: CPAN reverse dependencies
by toolic (Bishop) on Nov 02, 2010 at 22:49 UTC
Re: CPAN reverse dependencies
by Khen1950fx (Canon) on Nov 03, 2010 at 10:41 UTC
    An easy way to get reverse dependencies is to use cpangraph. You'd run it like this:
    cpangraph --reverse CGI
    It'll produce a svg graph in the current directory. Use your browser to view it. Now, to get to the point where you can run that command, you'll need to install CPANDB::Generator. Then run this:
    #!/usr/bin/perl use strict; use warnings; use CPANDB::Generator; my $cpan = CPANDB::Generator->new( cpan => '/root/.cpan', sqlite => '/root/CPANDB.sqlite', )->run;
    That will fetch the sqlite database necessary to get the dependencies. It'll take time, so be patient. Next, make sure that your system can handle svg. Here's a bundle that I used, and, trust me, it works. The whole process will take a couple of hours, so hang tight. Then you're good to go.
    #!/usr/bin/perl use strict; use warnings; use CPAN; CPAN::Shell->force('install', "Test", "Test::More", "URI", "LWP::Simple", "LWP::Online", "Time::HiRes", "Getopt::Long", "List::Util", "Scalar::Util", "Math::Complex", "Graph::Directed", "SVG::XML", "GD::SVG", "XML::Parser", "XML::SAX", "SVG::Parser", "Pod::Usage", "XML::Twig", "SVG::Metadata", "Class::Date", "Clone", "Image::ExifTool", "Math::Trig", "Readonly", "Template", "Template::Provider::FromDATA", "Test::Kwalitee", "Test::Perl::Critic", "version", "Test::Pod", "Test::Pod::Coverage", "Test::Spelling", "SVG::Calendar", "Statistics::Descriptive", "Tree::DAG_Node", "Math::Spline", "Math::Derivative", "SVG::Graph", "Transform::Canvas", "Data::Dumper", "Config::General", "SVG::Template::Graph", "DateTime", "HTTP::Date", "Compress::Zlib", "XML::XPath", "Math::BaseCnv", "XML::Tidy", "SVG::TT::Graph", "Geo::ShapeFile", "Date::Simple", "XML::Generator::SVG::ShapeFile", "SVG::DOM2", "GD::Text", "UML::Sequence", "IO::String", "Image::Info", "Test::NoWarnings", "Graphics::ColorNames", "Graphics::ColorNames::WWW", "SVG::Sparkline", "Class::Accessor", "Cairo", "Pango", "Params::Validate", "Exception::Class", "Test::Exception", "SVG::Rasterize", "Graph::Easy", "Graph::Easy::As_svg", "Class::Accessor::Fast", "Module::Load", "Module::Pluggable::Fast", "XML::LibXML", "SVG::Convert", "SVGGraph::Pie", "Test::XML", "Algorithm::Points::MinimumDistance", "SVG::Plot", "SVGraph", "Heap", "Graph::Usage");
Re: CPAN reverse dependencies
by Tux (Canon) on Nov 03, 2010 at 13:38 UTC

    As cpangraph only produces a (nice) image, I still prefer text (and not that many dependencies.

    Starting with CPANDB, created this script, that provides me with the desired output:

    $ cpan-rev --help usage: cpan-rev [-v [1]] [-l 99] [--no-down] [--no-modules] mod|dist --verbose=1 Set verbosity level (0) --max-level=99 Maximum depth for tracking upwards (99) --no-modules Do not show modules in the dist mod|dist Sthe module (Text::CSV_XS) or dist (Text-CSV_XS) nam +e $ cpan-rev Spreadsheet::Read Spreadsheet-Read HMBRAND 39/ 0/ + 0/ 0 - Spreadsheet::Read 0.40 App-ErrorCalculator SMUELLER 11/ 1/ + 27/ 0 - App::ErrorCalculator 1.02 NetSDS-Util RATTLER 76/ 3/ + 3/ 0 - NetSDS::Util 1.044 - NetSDS::Util::Convert 1.044 - NetSDS::Util::DateTime 1.044 - NetSDS::Util::File 1.044 - NetSDS::Util::FileImport 1.044 - NetSDS::Util::Misc 1.044 - NetSDS::Util::String 1.044 - NetSDS::Util::Struct 1.044 - NetSDS::Util::Translit 1.044 - NetSDS::Util::Types 1.044 NetSDS-Kannel RATTLER 0/ 0/ + 6/ 0 - NetSDS::Feature::Kannel 1.300 - NetSDS::Kannel 1.300 NetSDS-Kannel RATTLER 0/ 0/ + 6/ 0 - NetSDS::Feature::Kannel 1.300 - NetSDS::Kannel 1.300 NetSDS-Message RATTLER 8/ 2/ + 0/ 0 - NetSDS::Const::Message 0.021 - NetSDS::Message 0.021 - NetSDS::Message::SMS 0.021 - NetSDS::Util::SMS 0.021 NetSDS-Queue RATTLER 7/ 3/ + 0/ 0 - NetSDS::App::QueueProcessor 0.032 - NetSDS::Queue 0.032 NetSDS-SMPP RATTLER 0/ 1/ + 2/ 0 - NetSDS::App::SMPP 1.200 NetSDS-Kannel RATTLER 0/ 0/ + 6/ 0 - NetSDS::Feature::Kannel 1.300 - NetSDS::Kannel 1.300 NetSDS-Message RATTLER 8/ 2/ + 0/ 0 - NetSDS::Const::Message 0.021 - NetSDS::Message 0.021 - NetSDS::Message::SMS 0.021 - NetSDS::Util::SMS 0.021 NetSDS-SMPP RATTLER 0/ 1/ + 2/ 0 - NetSDS::App::SMPP 1.200 PerlIO-via-csv SLANNING 122/ 10/ + 0/ 0 - PerlIO::via::csv 0.01 Task-BeLike-LESPEA LESPEA 0/ 0/ + 0/ 0 - Task::BeLike::LESPEA 1.11 $ cpan-rev --no-modules Text-CSV_XS Text-CSV_XS HMBRAND 233/ 2/ + 0/ 0 Apache-FastForward JWACH 5/ 16/ + 0/ 0 App-CCSV GARGAMEL 144/ 0/ + 3/ 0 App-CSV GAAL 102/ 0/ + 14/ 0 App-Hachero DANJOU 70/ 1/ + 0/ 0 Authen-UserVerify TERENCEMO 105/ 0/ + 0/ 0 Bio-MAGETAB TFRAYNER 20/ 1/ + 1/ 0 Business-OnlinePayment-AuthorizeNet IVAN 0/ 0/ + 38/ 0 Business-OnlinePayment-Vanco JEF 86/ 0/ + 0/ 0 CGI-Application-Framework RDICE 1/ 0/ + 6/ 0 CGI-Application-Plugin-Output-XSV ZACKSE 140/ 0/ + 0/ 0 Class-CSV DJR 109/ 1/ + 0/ 0 DBD-CSV HMBRAND 38/ 1/ + 7/ 0 ASNMTAP ASNMTAP 0/ 0/ + 1/ 0 CGI-Application-Demo-Ajax RSAVAGE 43/ 0/ + 0/ 0 CGI-Application-Util-Diff RSAVAGE 42/ 0/ + 0/ 0 Data-Toolkit AFINDLAY 106/ 0/ + 8/ 0 Gtk2-Ex-DBITableFilter OFEYAIKON 0/ 0/ + 0/ 0 Gtk2-Ex-Threads-DBI OFEYAIKON 0/ 0/ + 10/ 0 Gtk2-Ex-DBITableFilter OFEYAIKON 0/ 0/ + 0/ 0 Mail-Abuse LUISMUNOZ 13/ 5/ + 35/ 0 Report-Generator REHSACK 60/ 0/ + 0/ 0 App-Report-Generator REHSACK 61/ 0/ + 3/ 0 Task-BeLike-LESPEA LESPEA 0/ 0/ + 0/ 0 Trash-Park MSCHILLI 46/ 0/ + 2/ 0 Data-BT-PhoneBill TMTM 71/ 0/ + 0/ 0 Data-Toolkit AFINDLAY 106/ 0/ + 8/ 0 Finance-Bank-DE-NetBank RMORIZ 67/ 0/ + 1/ 0 IO-StructuredOutput UNRTST 96/ 0/ + 0/ 0 Log-Accounting-CSV GUGOD 15/ 1/ + 39/ 0 Logfile-EPrints TIMBRODY 86/ 12/ + 3/ 0 Mac-Apps-Seasonality-LoadICAOHistory ELLIOTJS 0/ 20/ + 9/ 0 Mail-Abuse LUISMUNOZ 13/ 5/ + 35/ 0 Module-CPANTS-Analyse CHORNY 522/ 1/ + 2/ 0 Module-CPANTS-ProcessCPAN DOMM 22/ 0/ + 14/ 0 Module-CPANTS-Site DOMM 0/ 3/ + 8/ 0 Module-CPANTS-Site DOMM 0/ 3/ + 8/ 0 Task-BeLike-FLORA FLORA 12/ 0/ + 0/ 0 Test-Apocalypse APOCAL 17/ 0/ + 0/ 0 Acme-Mom-Yours ADAMK 21/ 0/ + 0/ 0 Dist-Zilla-Plugin-ApocalypseTest APOCAL 13/ 0/ + 1/ 0 Test-Dist MONS 70/ 0/ + 2/ 0 Test-Kwalitee CHROMATIC 518/ 2/ + 6/ 0 Bundle-JONASBN JONASBN 4/ 0/ + 0/ 0 Business-DK-CPR JONASBN 29/ 0/ + 0/ 0 Business-DK-CVR JONASBN 90/ 0/ + 0/ 0 Business-DK-CPR JONASBN 29/ 0/ + 0/ 0 Business-DK-Phonenumber JONASBN 71/ 0/ + 1/ 0 Dist-Zilla-Plugin-KwaliteeTests MARCEL 87/ 0/ + 3/ 0 Dist-Zilla-PluginBundle-JQUE JQUELIN 8/ 0/ + 0/ 0 Task-Dist-Zilla JQUELIN 0/ 0/ + 0/ 0 Task-BeLike-hanekomu MARCEL 0/ 0/ + 0/ 0 Dist-Zilla-PluginBundle-KENT KENTNL 26/ 0/ + 0/ 0 Task-Dist-Zilla JQUELIN 0/ 0/ + 0/ 0 Task-BeLike-hanekomu MARCEL 0/ 0/ + 0/ 0 Task-Dist-Zilla JQUELIN 0/ 0/ + 0/ 0 Task-BeLike-hanekomu MARCEL 0/ 0/ + 0/ 0 Dist-Zilla-PluginBundle-MARC MARCEL 3/ 0/ + 0/ 0 Task-Dist-Zilla JQUELIN 0/ 0/ + 0/ 0 Task-BeLike-hanekomu MARCEL 0/ 0/ + 0/ 0 Task-BeLike-hanekomu MARCEL 0/ 0/ + 0/ 0 Task-Dist-Zilla JQUELIN 0/ 0/ + 0/ 0 Task-BeLike-hanekomu MARCEL 0/ 0/ + 0/ 0 Task-BeLike-LESPEA LESPEA 0/ 0/ + 0/ 0 Task-Dist-Zilla JQUELIN 0/ 0/ + 0/ 0 Task-BeLike-hanekomu MARCEL 0/ 0/ + 0/ 0 Net-Hulu JLOPHTY 15/ 0/ + 1/ 0 POE-Component-SimpleLog APOCAL 253/ 1/ + 0/ 0 Task-POE-All APOCAL 21/ 0/ + 0/ 0 Task-BeLike-JONASBN JONASBN 1/ 0/ + 0/ 0 Task-Toolchain-Test OVID 31/ 0/ + 0/ 0 WebService-Jamendo-RSS JLOPHTY 24/ 0/ + 0/ 0 POE-Filter-CSV_XS BINGOS 325/ 0/ + 0/ 0 Task-POE-All APOCAL 21/ 0/ + 0/ 0 PSPP-Wrapper PDONELAN 0/ 0/ + 0/ 0 Parse-CSV ADAMK 357/ 0/ + 0/ 0 Business-AU-Data-ANZIC ADAMK 100/ 0/ + 0/ 0 Data-Package-CSV ADAMK 131/ 0/ + 0/ 0 Parse-CPAN-Ratings LBROCARD 112/ 0/ + 0/ 0 CPANDB-Generator ADAMK 13/ 0/ + 0/ 0 SQLite-Archive ADAMK 93/ 0/ + 0/ 0 Tie-File-AnyData-MultiRecord_CSV MOTIF 135/ 1/ + 0/ 0 Parse-GutenbergRoget RJBS 100/ 0/ + 0/ 0 RDF-SKOS DRRHO 0/ 0/ + 0/ 0 RT-View-ConciseSpreadsheet JESSE 6/ 0/ + 0/ 0 Task-BeLike-BINGOS BINGOS 11/ 0/ + 0/ 0 Task-BeLike-LESPEA LESPEA 0/ 0/ + 0/ 0 Task-Kensho APEIRON 30/ 1/ + 0/ 0 Task-SDK-Perigrin PERIGRIN 21/ 0/ + 0/ 0 Task-WebGUI PDONELAN 17/ 0/ + 0/ 0 Text-CSV-Simple TMTM 129/ 0/ + 6/ 0 Business-Shipping-DataTools DBROWNING 0/ 0/ + 0/ 0 GPS-Tracer TULSOFT 46/ 18/ + 0/ 0 Text-CSV-Track JKUTEJ 105/ 2/ + 8/ 0 Text-ECSV JKUTEJ 124/ 1/ + 27/ 0 Tie-Handle-CSV DANBOO 51/ 0/ + 1/ 0 Tripletail HIO 20/ 0/ + 6/ 0 VANAMBURG-SEMPROG-SimpleGraph VANAMBURG 22/ 0/ + 1/ 0 WWW-Analytics-MultiTouch JJSCHUTZ 46/ 0/ + 3/ 0 WWW-CybozuOffice6 KAZUHO 88/ 0/ + 1/ 0 Webservice-InterMine INTERMINE 0/ 1/ + 21/ 0 dbMan MILSO 34/ 1/ + 0/ 0 hwd PETDANCE 69/ 0/ + 0/ 0 xDash JWACH 8/ 0/ + 0/ 0 $

    Enjoy, Have FUN! H.Merijn
Re: CPAN reverse dependencies
by Anonymous Monk on Nov 02, 2010 at 22:50 UTC
Re: CPAN reverse dependencies
by fod (Friar) on Nov 03, 2010 at 02:14 UTC
    Coincidentally, this link (cpan-mangler) was submitted to perl reddit today. Among other things it adds number of dependents to cpan search results.

      cpan-mangler depends on AnyEvent, which is MLEHMANware, and thus forbidden. Sorry, it is a no-go.


      Enjoy, Have FUN! H.Merijn

        For you, it may be a no-go, but there are many other people who use it. And API-wise, AnyEvent isn't bad, and I think it's a better API than POE, for example.

        I understand that you are suspicious of modules because of their author, and I have such a "blacklist" of authors as well. But I don't find it constructive to reject modules without telling people at least why you find them unacceptable to use, especially if it is for reasons having more to do with the author than with the module(s).

      Gah!