#!/usr/local/bin/perl -w

use strict;
use Net::HTTP;

my $s=Net::HTTP->new(Host => "www.moensted.dk");
$s->write_request(
	GET                 => "/spam/drbsites.txt"
);
my($code,$mess,%h)=$s->read_response_headers;
return 0 if ($code!=200);

my $string="";
while (1) {
    my $buf;
    my $n = $s->read_entity_body($buf, 1024);
    last unless $n;
    $string.=$buf;
}

open(FOUT,">rbllookup-moensted.conf");
print FOUT "[MOENSTED]\n";
my $foundarray=0;
foreach my $line (split(/\n/,$string)) {
#    print "$line\n";

    if ($line eq "\@drbsites = (") {
	$foundarray=1;
	next;
    }

    next if (!$foundarray);

    if ($line eq ");") {
	$foundarray=0;
	next;
    }

    next if ($line=~/^#/);

    my @w=split(/;/,$line);
    my $url=$w[1];
    print FOUT "$url\n";
}

close(FOUT);
