netselct-apt is used to select the fastest mirrors (one non-us, one of any origin) for debian package retrieval. It has two main shortcomings - it clobbers sources.list in the current directory and it only picks one mirror of each type. Both of these are fixed with the below script. Hope you find it useful!

usage: script.pl [distro] [#mirrors] >> /etc/apt/sources.list
#! /usr/bin/perl -w use strict; if (scalar(@ARGV)==0){ print "#Usage: [stable|unstable|testing] [number of mirrors]\n +#Assuming \"stable\" and \"3\"\n"; } my ($distro,$howMany)=@ARGV; $distro="stable" if (!defined($distro)); $howMany = 3 if (!defined($howMany)); &displayList ("$distro", &selectSome($howMany,&getMirrors("^Packages") +)); &displayList ("$distro/non-US", &selectSome($howMany,&getMirrors("Non- +US packages"))); sub displayList { my $distro=shift; my @mirrors=@_; foreach (@mirrors){ print "deb $_ $distro main contrib non-free\n"; print "# deb-src deb $_ $distro main contrib non-free\ +n"; } } sub getMirrors { my $search=shift; my $invert=shift; $search="." if (!defined($search)); my @mirrorPage = `lynx -source "http://www.debian.org/mirror/m +irrors_full"`; my @mirrors; foreach (@mirrorPage){ if ($_=~/(.*)<a href="(http:\/\/.*?)">/) { my $description=$1; my $url=$2; push @mirrors,$url if ($invert && $description!~/$ +search/i); push @mirrors,$url if (!$invert && $description=~/ +$search/i); } } return @mirrors; } sub selectSome { my $howMany=shift; my @list = @_; my $command = "netselect -v -s $howMany ".join (' ',@list); my @arr = split(/\n/,`$command`); foreach (@arr){ $_=~s/\s*-?\d+\s*([a-z]+:\/\/.*)/$1/i; #snag url } return @arr; }