Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Install all favorited distributions
#!/usr/bin/env perl
use strict;
use warnings;
use 5.010;
use Mojo::UserAgent;
my $url = shift @ARGV or die "Usage: $0 metacpan_author_url";
my $ua = Mojo::UserAgent->new;
my $dom = $ua->get($url)->res->dom;
my @modules = $dom->find('td.release a')->pluck('text')->each;
for my $module (@modules) {
$module =~ s/-/::/g;
qx/cpanm $module/;
}
# and another solution proposed from Stephen Thirlwall (sdt) (see comment below)
cpan_favorites() {
perl -Mojo -E "g('https://metacpan.org/author/$1')->dom('td.release a')->pluck('text')->each(sub{s/-/::/g;say})"
}
@dpetrov

This comment has been minimized.

Show comment Hide comment
@dpetrov

dpetrov Nov 7, 2012

DDP was added for debugging only and is not really needed

Owner

dpetrov commented Nov 7, 2012

DDP was added for debugging only and is not really needed

@sdt

This comment has been minimized.

Show comment Hide comment
@sdt

sdt Nov 8, 2012

Oh nice - thanks for this!

I saw this post http://blogs.perl.org/users/steven_haryanto/2012/10/your-own-taskbelikeauthorfavorited.html and thought it might be better to just feed the favorites list into cpanm, rather than uploading something onto cpan.

Here's a one-line version you can stick in your .bashrc:

install_cpan_favorites() {
  perl -Mojo -E "s/-/::/g and qx(cpanm \$_) for g('https://metacpan.org/author/$1')->dom('td.release a')->pluck('text')->each";
}

usage: install_cpan_favorites $username

(somewhat inspired by this thread: https://groups.google.com/forum/?fromgroups=#!topic/mojolicious/iTVzzjX5pPQ)

sdt commented Nov 8, 2012

Oh nice - thanks for this!

I saw this post http://blogs.perl.org/users/steven_haryanto/2012/10/your-own-taskbelikeauthorfavorited.html and thought it might be better to just feed the favorites list into cpanm, rather than uploading something onto cpan.

Here's a one-line version you can stick in your .bashrc:

install_cpan_favorites() {
  perl -Mojo -E "s/-/::/g and qx(cpanm \$_) for g('https://metacpan.org/author/$1')->dom('td.release a')->pluck('text')->each";
}

usage: install_cpan_favorites $username

(somewhat inspired by this thread: https://groups.google.com/forum/?fromgroups=#!topic/mojolicious/iTVzzjX5pPQ)

@sdt

This comment has been minimized.

Show comment Hide comment
@sdt

sdt Nov 8, 2012

I think I prefer this which just lists them out, and then feed that into xargs cpanm or whatever:

cpan_favorites() {
  perl -Mojo -E "g('https://metacpan.org/author/$1')->dom('td.release a')->pluck('text')->each(sub{s/-/::/g;say})"
}

sdt commented Nov 8, 2012

I think I prefer this which just lists them out, and then feed that into xargs cpanm or whatever:

cpan_favorites() {
  perl -Mojo -E "g('https://metacpan.org/author/$1')->dom('td.release a')->pluck('text')->each(sub{s/-/::/g;say})"
}
@dpetrov

This comment has been minimized.

Show comment Hide comment
@dpetrov

dpetrov Nov 9, 2012

That is really nice and I've already added it into my .bashrc :) I think also that the seconds version where you can pipe the output to cpanm is preferable. Thanks for the follow u and sharing it

Owner

dpetrov commented Nov 9, 2012

That is really nice and I've already added it into my .bashrc :) I think also that the seconds version where you can pipe the output to cpanm is preferable. Thanks for the follow u and sharing it

@dolmen

This comment has been minimized.

Show comment Hide comment
@dolmen

dolmen Jan 18, 2013

@dpetrov

This comment has been minimized.

Show comment Hide comment
@dpetrov

dpetrov Jan 18, 2013

Thanks @dolmen. Just saw the tweet and was checking it out ;)

Owner

dpetrov commented Jan 18, 2013

Thanks @dolmen. Just saw the tweet and was checking it out ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment