Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
What does perl(Foo::Bar) mean? Is that a Perl package? – Ken Kinder Feb 29 '12 at 20:46
I'm going with's a perl module. He's trying to find out what apt package provides a particular perl module. – RobotHumans Feb 29 '12 at 23:14
@Ken: yes it is. – 0xC0000022L Mar 1 '12 at 17:09
@maggotbrain: I'd love if it was, because then the question would be answered. Unfortunately the example in the other question is an entirely different subset of the yum functionality and has nothing whatsoever to do with my question. Had I asked about something that provides a particular file by path, your assumption would be correct, though. Same for the linked SO-question - completely unrelated. – 0xC0000022L Aug 16 '13 at 21:03
Notice that apt-file specifies the package associated with the file, so it is a close answer. For example, if is provided by baz-perl, this package will appear on the output. I don't think there is an APT command for specifying a perl module in the way you want, though. Looks like a convenience too convenient. I think this question is better suited to Unix & Linux. – edwin Aug 16 '13 at 21:25

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/
perl-modules: /usr/share/perl/5.14.2/Net/

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
    For command based protocols (FTP, SMTP etc)
    Installed: 2.29
    CPAN:      2.30  Not up to date
    Graham Barr (GBARR)

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}'

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/
perl-modules: /usr/share/perl/5.14.2/Net/

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

share|improve this answer
That's pretty good, especially if I can combine it with apt-file (which I use on most of my Ubuntu boxes). Thanks and +1. Let me dig into this a bit more before accepting it. – 0xC0000022L Aug 16 '13 at 23:05
I changed the way it finds the name, so dpkg -S won't fail when CPAN reports different path than where it is actually installed. – Braiam Aug 16 '13 at 23:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.