#!/usr/bin/perl
use strict;
my $myids="[0-9A-F]{8}(26841D5B|4B3A135C)";

while(<STDIN>) { chomp; my $line = $_;
	if (/^(pub +[0-9]+[DR]\/([0-9A-Z]{8}) [0-9\-]{10} .*)/) {
		my $thiskey = $2;
		my $found;
		do {
			local $_;
			system("gpg --recv-keys $thiskey");
			open(GPG,"gpg --with-colons --list-sigs $thiskey |");
			while(<GPG>) {
				if (/^sig:::.*:$myids:[0-9\-]{10}:/) {
					print stderr "Have already signed key $thiskey.\n";
					$found = 1;
					last;
				}
			}
			close(GPG);
		};
		if ($found) {
			print "(".$line.")\n";
		} else {
			print $line."\n";
		}
	} else { print $line."\n"; }
}
