The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Dist::Util - Dist-related utilities

VERSION

This document describes version 0.071 of Dist::Util (from Perl distribution Dist-Util), released on 2022-08-21.

SYNOPSIS

use Dist::Util qw(
    list_dist_modules
    list_dists
    packlist_for
);

say packlist_for("Text::ANSITable"); # sample output: /home/steven/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/x86_64-linux/auto/Text/ANSITable/.packlist
my @mods = list_dist_modules("Text::ANSITable"); # -> ("Text::ANSITable", "Text::ANSITable::BorderStyle::Default", "Text::ANSITable::ColorTheme::Default")

DESCRIPTION

FUNCTIONS

packlist_for($mod) => STR

Find .packlist file for installed module $mod (which can be in the form of Package::SubPkg or Package/SubPkg.pm). Return undef if none is found.

Depending on the content of @INC, the returned path may be absolute or relative.

Caveat: many Linux distributions strip .packlist files.

list_dists

Usage:

list_dists(%opts) => LIST

Find all .packlist files in @INC and then pick the dist names from the paths, because .packlist files are put in:

$INC/$Config{archname}/auto/Foo/Bar/.packlist

Caveat: many Linux distributions strip .packlist files.

TODO: Instead of via .packlist, also try querying the OS package manager.

Known options:

  • detail

    Bool. If set to true, instead of a list of distribution names, the function will return a list of hashrefs containing detailed information e.g.:

    (
      {dist=>"Foo-Bar", packlist=>"/home/u1/perl5/perlbrew/perls/perl-5.34.0/lib/site_perl/5.34.0/x86_64-linux/auto/Foo/Bar/.packlist"},
      ...
    )

list_dist_modules($mod) => LIST

Given installed module name $mod (which must be the name of the main module of its distribution), list all the modules in the distribution. This is done by first finding the .packlist file, then look at all the .pm files listed in the packlist.

Will return empty list if fails to get the packlist.

Caveat: many Linux distributions strip .packlist files.

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/Dist-Util.

SOURCE

Source repository is at https://github.com/perlancar/perl-Dist-Util.

SEE ALSO

Dist::Util::Current

AUTHOR

perlancar <perlancar@cpan.org>

CONTRIBUTOR

Steven Haryanto <stevenharyanto@gmail.com>

CONTRIBUTING

To contribute, you can send patches by email/via RT, or send pull requests on GitHub.

Most of the time, you don't need to build the distribution yourself. You can simply modify the code, then test via:

% prove -l

If you want to build the distribution (e.g. to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond that are considered a bug and can be reported to me.

COPYRIGHT AND LICENSE

This software is copyright (c) 2022, 2014 by perlancar <perlancar@cpan.org>.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Dist-Util

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.