From: Alexander Wirt Date: Tue, 1 Nov 2011 22:32:35 +0000 (+0100) Subject: Add a smple masterlist2mirmon converter X-Git-Url: http://git.grml.org/?p=grml-mirrors.git;a=commitdiff_plain;h=4b8a89e9ea7620e0d73e351d4209a4978280c32e Add a smple masterlist2mirmon converter --- diff --git a/masterlist2mirmon b/masterlist2mirmon new file mode 100755 index 0000000..f191686 --- /dev/null +++ b/masterlist2mirmon @@ -0,0 +1,31 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +my $file = shift; + +die "no file $file" unless -f $file; + +open (my $fh, '<', $file) or die "Could not open $file: $!"; + +my @mirrors; +my $data; +while (my $line = <$fh>) { + chomp $line; + if ($line =~ /([^:]+): (.*)/) { + my $key = lc($1); + my $value = $2; + $data->{$key} = $value; + } elsif ($line eq '') { + push @mirrors, $data; + $data = undef; + } else { + print "Malformed line: $line\n"; + } +} + +foreach my $mirror (@mirrors) { + my ($c, $r) = split (/ +/, $mirror->{'country'}); + printf ("%s http://%s%s\n", $c, $mirror->{'site'}, $mirror->{'grml-http'}); +}