Wednesday, March 30, 2011

Download Alien Bob's multilib support packages

I've created a Perl script to download all slackware-current multilib support packages from here. Perl really makes you a lazy programmer. You can do unbelievable many things in just a few lines.
#!/usr/bin/perl -w

use LWP::UserAgent;
use strict;

sub get_links
{
my $url = shift;
my $page = LWP::UserAgent->new->get($url)->content;

map { m@/$@ && get_links($_) || system("wget -xnH $_"); }
map { "$url$_" } $page =~ m@<a href="(.+)">\1</a>@g;
}

my $url = "http://connie.slackware.com/~alien/multilib/current/";

get_links($url);