Dist::Util::Current - Guess the current Perl distribution name
This document describes version 0.003 of Dist::Util::Current (from Perl distribution Dist-Util-Current), released on 2022-11-07.
use Dist::Util::Current qw(my_dist); my $dist = my_dist();
Usage:
my_dist(%opts) => STR|HASH
Guess the current distribution (the Perl distribution associated with the source code) using one of several ways.
Options:
filename
String. The path to source code file. If unspecified, will use file name retrieved from caller(0).
caller(0)
package
String. The caller's package. If unspecified, will use package name retrieved from caller(0).
How the function works:
If the caller's package defines a package variable $DIST, will return this.
$DIST
Will check .packlist for module or supermodules. For example, if module is Algorithm::Backoff::Constant then will try to check for .packlist for Algorithm::Backoff::Constant, Algorithm::Backoff, and Algorithm.
Algorithm::Backoff::Constant
Algorithm::Backoff
Algorithm
For each found .packlist will read its contents and check whether the filename is listed. If yes, then we've found the distribution name and return it.
@INC
Will check .packlist in directories listed in @INC. Will use Dist::Util's list_dists() for this.
list_dists()
this_dist()
Will guess using App::ThisDist's this_dist() against the current directory and several levels up.
If all of the above fails, we return undef.
TODO: Query the OS's package manager.
Please visit the project's homepage at https://metacpan.org/release/Dist-Util-Current.
Source repository is at https://github.com/perlancar/perl-Dist-Util-Current.
App::ThisDist
Dist::Util
perlancar <perlancar@cpan.org>
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.
This software is copyright (c) 2022 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.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Dist-Util-Current
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.
To install Dist::Util::Current, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Dist::Util::Current
CPAN shell
perl -MCPAN -e shell install Dist::Util::Current
For more information on module installation, please visit the detailed CPAN module installation guide.