Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Installing CPAN modules

by DaveK (Initiate)
on Jan 30, 2019 at 02:35 UTC ( #1229140=perlquestion: print w/replies, xml ) Need Help??

DaveK has asked for the wisdom of the Perl Monks concerning the following question:

I want to install all modules that start with Tk: using only a single command line. I was hoping for something like this cpanm install Tk:* How can I do this? I have searched the web but cannot find anything that will help me.

Replies are listed 'Best First'.
Re: Installing CPAN modules
by huck (Prior) on Jan 30, 2019 at 07:14 UTC

    This may help get you started

    use strict; use warnings; #https://www.perlmonks.org/?node_id=1160177 use Storable qw(store retrieve freeze thaw dclone); my $meta = retrieve('C:/Perl/cpan/Metadata'); die "Unable to retrieve from meta!\n" unless defined $meta; #print 'Keys:',join(' ',keys(%$meta)),"\n"; my @wanted; for my $mod (keys(%{$meta->{'CPAN::Module'}})) { next unless ($mod=~m/^Tk/); push @wanted,$mod; } for my $mod (sort @wanted){ print 'cpan -i ' ,$mod,"\n"; } exit;
Re: Installing CPAN modules
by atcroft (Abbot) on Jan 31, 2019 at 01:08 UTC

    For that matter, why not the following (using just the CPAN modules)?

    # Almost no testing, so be warned... perl -Mstrict -Mwarnings -MCPAN -le ' CPAN::HandleConfig->load; CPAN::Shell::setup_output; CPAN::Index->reload; CPAN::HandleConfig::edit( q{prerequisites_policy follow}, ); my @tk_modules = grep { $_->id =~ m/^\bTk\b(?:::.*)?$/i; } CPAN::Shell->expand( q{Module}, q{/./}, ); foreach my $mod ( @tk_modules ) { print qq{Attempting install of }, $mod->id; CPAN::Shell->install($mod); } '

    Hope that helps.

    Update: 2019-01-30 - Changed regex from /^\bTk\b/i to /^\bTk\b(?:::.*)?$/i to get only Tk and Tk::* modules.

Re: Installing CPAN modules
by Anonymous Monk on Jan 30, 2019 at 03:46 UTC

    One way is make where you specify what & how to run some command(s). Another is create a perl package (does not have to be a perl package, could be OS specific package) which will list all the Tk software as requisites. Then either run the make command or install the perl package.

      Of course, nothing is stopping you to feed each module name (similar work is needed for other two methods) in a loop to the CPAN installer.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1229140]
Approved by NetWallah
Front-paged by haukex
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2023-02-07 15:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (40 votes). Check out past polls.

    Notices?