+sub ct
+{
+ my $l = shift;
+ my $p = shift;
+ my @a = @_;
+ my $ref = $pre{$p};
+ if ($ref) {
+ my $a;
+ foreach $a (@a) {
+ # for now remove (nn) [nn]
+ my ($itu) = $a =~ /(\(\d+\))/; $a =~ s/(\(\d+\))//g;
+ my ($cq) = $a =~ /(\[\d+\])/; $a =~ s/(\[\d+\])//g;
+ my ($lat, $long) = $a =~ m{(<[-+\d.]+/[-+\d.]+>)}; $a =~ s{(<[-+\d.]+/[-+\d.]+>)}{}g;
+
+ unless ($a) {
+ print "line $line: blank prefix on $l in cty.dat\n";
+ next;
+ }
+ next if $a eq $p; # ignore if we have it already
+ my $nref = $pre{$a};
+ $pre{$a} = $ref if !$nref; # copy the original ref if new
+ }
+ } else {
+ print "line $line: unknown prefix '$p' on $l in cty.dat\n";
+ }
+}
+