Subject: | Suggestion: an option to return paths |
Just wondering if there is any interest in introducing something like a 'return_path' option to list_modules(). So instead of just returning undef in the values of the returned hash, we return file paths instead.
I find this useful sometimes when wanting to collect module files (e.g. to parse their version numbers). Currently to do this we need an extra step of performing something like Module::Path::module_path() for every module returned by Module::List. Which is twice slow.
I'm implementing it in my fork:
https://github.com/perlancar/perl-PERLANCAR-Module-List/commit/957404b12ae9e3e17054e30f08085497bbfafee0
Example:
list_modules("IPC::", {list_modules=>1, return_path=>1});
would return:
{
"IPC::Cmd" => "/home/s1/perl5/perlbrew/perls/perl-5.22.0/lib/5.22.0/IPC/Cmd.pm",
"IPC::Lockfile" => "/home/s1/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/IPC/Lockfile.pm",
"IPC::Msg" => "/home/s1/perl5/perlbrew/perls/perl-5.22.0/lib/5.22.0/x86_64-linux/IPC/Msg.pm",
"IPC::Open2" => "/home/s1/perl5/perlbrew/perls/perl-5.22.0/lib/5.22.0/IPC/Open2.pm",
"IPC::Open3" => "/home/s1/perl5/perlbrew/perls/perl-5.22.0/lib/5.22.0/IPC/Open3.pm",
"IPC::Run" => "/home/s1/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/IPC/Run.pm",
"IPC::Run3" => "/home/s1/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/IPC/Run3.pm",
"IPC::Semaphore" => "/home/s1/perl5/perlbrew/perls/perl-5.22.0/lib/5.22.0/x86_64-linux/IPC/Semaphore.pm",
"IPC::SharedMem" => "/home/s1/perl5/perlbrew/perls/perl-5.22.0/lib/5.22.0/x86_64-linux/IPC/SharedMem.pm",
"IPC::SysV" => "/home/s1/perl5/perlbrew/perls/perl-5.22.0/lib/5.22.0/x86_64-linux/IPC/SysV.pm",
}