#!/usr/bin/perl -w

use strict;
use MIME::Base64;
use Data::Dumper;

my $skip = 1;
my $data;
my $host;

while(<>) {
	chomp;
	if (/^\.$/) {
		$skip = 0;
		$host = undef;
		next;
	}
	next if ($skip);
	if (! $host) {
		$host = $_;
		next;
	}
	push @{$data->{$host}},$_;
}

print Dumper($data);

foreach my $host (keys %{$data}) {
	print "host: $host\n";

	foreach my $name (@{ $data->{$host} }) {

		my $data = shift @{ $data->{$host} };
		if ($data =~ /^([A-Za-z0-9\+\=\/]+)/) {
			$data = decode_base64($1);
		} else {
			die "can't decode '$data'!";
		}

		printf("%-20s %s\n", $name, $data);
	}

}
