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; # 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.