[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Utility to install a perl module via apt with cpan fallback



Hey All,

I was recently asked if I was aware of a utility that would allow a
user to attempt to install module by first checking the apt
repository, then falling back to a regular CPAN install if that
failed.

A few minutes of hacking gave me this:

#!/usr/bin/perl

use strict;
use warnings;

my( $mod ) = shift;
( my $file = "perl5/${mod}.pm" ) =~ s{::}{/}g;

my $r = `apt-file search $file`;

if( $r ) {
    my( $p ) = split( /:/, $r, 2 );
    exec "apt-get install $p";
}
else {
    exec "cpan $mod";
}


That's a pretty simplistic start. It was suggested to me that I should
post it to the list and see if anyone can improve on what I have so
far.

I think many people would want a utility like this, I'll be interested
to see what you all can come up with.

-Brian


Reply to: