4

This is certainly related to this question, but I feel it doesn't overlap, so here we go. How can I get the functionality of the following command on Ubuntu (and/or Debian as bonus):

yum whatprovides 'perl(Foo::Bar)'

Obviously I can attempt to rely on the package somehow ending up in a folder structure that resembles the namespaces in Perl, but I'm looking for something equivalent, i.e. equally brief and trivial. However, if it doesn't work as briefly on Ubuntu, I can do with a longer path and create my own function.

Please consider 10.04 or newer for this question.

0xC0000022L
  • 5,870

1 Answers1

4

If you are looking to a similar apt/dpkg function, I don't know one, but you can use this:

dpkg -S $(cpan -D Net::Cmd | grep pm | awk -F '/' '{print $NF}')
perl-modules: /usr/share/perl/5.14.2/IPC/Cmd.pm
perl-modules: /usr/share/perl/5.14.2/Net/Cmd.pm

You can use cpan -D module to find basic information about a module:

cpan -D Net::Cmd
Going to read '/home/braiam/.cpan/Metadata'
  Database was generated on Fri, 16 Aug 2013 21:53:02 GMT
Net::Cmd
-------------------------------------------------------------------------
    For command based protocols (FTP, SMTP etc)
    S/SH/SHAY/libnet-1.23.tar.gz
    /usr/share/perl/5.14/Net/Cmd.pm
    Installed: 2.29
    CPAN:      2.30  Not up to date
    Graham Barr (GBARR)
    gbarr@pobox.com

Then parse the module path, in my case I was lazy, you can use whatever you like to do this:

cpan -D Net::Cmd | grep pm | awk -F '/' '{print $NF}'
Cmd.pm

Then use command substitution:

dpkg -S $(cpan -D Net::Cmd | grep pm | awk -F '/' '{print $NF}')
perl-modules: /usr/share/perl/5.14.2/IPC/Cmd.pm
perl-modules: /usr/share/perl/5.14.2/Net/Cmd.pm

Hope is useful to you. BTW, this requires cpan installed (which is in most of the defaults installations).

Braiam
  • 69,112