G'day Lotus1,

[Firstly, I'm a bit late to the party with this. I started to write some code yesterday, was interrupted, and only got back to it about 24 hours later.]

"This seems likely to break in future use."

There are a number of issues, especially if you were hoping to turn this into a general solution. Here are the main ones as I see them. I acknowledge that, in some cases, I'm repeating what others have already said.

For testing, I chose the following distributions:

libwww-perl-6.15
This was already mentioned. It contains multiple modules. The tarball name (libwww-perl-6.15.tar.gz) does not reflect the module names (all of which are in the LWP namespace). This does have a single, common, top-level lib directory containing only *.pm files. See its MANIFEST file for details.
Qt4-0.99.0
This was useful as it demonstrated all the points I made above: bzip tarball (Qt4-0.99.0.tar.bz2); multiple modules (which are neither called Qt4 nor in a Qt4 namespace); there's no common, top-level lib directory; there are multiple lib subdirectories which contain *.pm and other files. See its MANIFEST file for details.
Authen-SASL-Perl-NTLM-0.003
This was what you were using. It was mainly for comparison: it doesn't demonstrate any of the points I made above. See its MANIFEST file for details.

For additional testing, I made .tar.bz2, .tgz and .tar versions of libwww-perl-6.15 and .tar.gz, .tgz and .tar versions of Qt4-0.99.0.

Here's my test code:

#!/usr/bin/env perl use 5.014; use strict; use warnings; use Archive::Tar; use List::Util qw{sum0}; use Test::More; my @test_data = ( { tarball_name_base => 'libwww-perl-6.15', filename_extensions => [qw{.tar.gz .tar.bz2 .tgz .tar}], expected_modules => [qw{ LWP LWP::Authen::Basic LWP::Authen::Digest LWP::Authen::Nt +lm LWP::ConnCache LWP::Debug LWP::DebugFile LWP::MemberMixin LWP::Protocol LWP::Protocol::GHTTP LWP::Protocol::cpan LWP::Protocol::data LWP::Protocol::file LWP::Protocol::ftp LWP::Protocol::gopher LWP::Protocol::http LWP::Protocol::loopback LWP::Protocol::mailto LWP::Protocol::nntp LWP::Protocol::nogo LWP::RobotUA LWP::Simple LWP::UserAgent }], }, { tarball_name_base => 'Qt4-0.99.0', filename_extensions => [qw{.tar.bz2 .tar.gz .tgz .tar}], expected_modules => [qw{ Phonon QImageBlitz Qsci Qt3Support4 QtCore4 QtCore4::class +info QtCore4::debug QtCore4::isa QtCore4::signals QtCore4::slot +s QtDBus4 QtDeclarative4 QtGui4 QtHelp4 QtMultimedia4 QtNetw +ork4 QtOpenGL4 QtScript4 QtSql4 QtSvg4 QtTest4 QtUiTools4 QtWeb +Kit4 QtXml4 QtXmlPatterns4 Qwt }], }, { tarball_name_base => 'Authen-SASL-Perl-NTLM-0.003', filename_extensions => [qw{.tar.gz}], expected_modules => [qw{Authen::SASL::Perl::NTLM}], }, ); plan tests => sum0 map { scalar @{$_->{filename_extensions}} } @test_d +ata; my $map_re = qr{(?x: ^ .*? \b lib / ( [^.]+ ) )}; my $grep_re = qr{(?x: ^ .*? \b lib / [^.]+ [.] pm )}; for my $tarball_test (@test_data) { for my $filename_extension (@{$tarball_test->{filename_extensions} +}) { my $tarball = $tarball_test->{tarball_name_base} . $filename_e +xtension; my $tar = Archive::Tar::->new(); $tar->read($tarball, '', {filter => qr{(?x: ^ [^/]* /? MANIFES +T $ )}}); my @manifest_lines = split /\R+/, $tar->get_content($tar->list +_files()); my @modules = map { (/$map_re/)[0] =~ s{/}{::}gr } grep { /$grep_re/ } @manifest_lines; is("@{[sort @modules]}", "@{[sort @{$tarball_test->{expected_modules}}]}", "Testing: $tarball"); } }

All of the expected_modules lists were taken directly from the distribution pages already linked to.

Here's the results:

1..9 ok 1 - Testing: libwww-perl-6.15.tar.gz ok 2 - Testing: libwww-perl-6.15.tar.bz2 ok 3 - Testing: libwww-perl-6.15.tgz ok 4 - Testing: libwww-perl-6.15.tar ok 5 - Testing: Qt4-0.99.0.tar.bz2 ok 6 - Testing: Qt4-0.99.0.tar.gz ok 7 - Testing: Qt4-0.99.0.tgz ok 8 - Testing: Qt4-0.99.0.tar ok 9 - Testing: Authen-SASL-Perl-NTLM-0.003.tar.gz

— Ken


In reply to Re: find module name from the module archive by kcott
in thread find module name from the module archive by Lotus1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.