X-Git-Url: http://www.dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FPrefix.pm;fp=perl%2FPrefix.pm;h=246dbb659eb2d53ead8a74d78c110140aec01cb9;hb=5b9ab81174d4a7734c92af52da6ddf89e980e321;hp=10559711961130312a3829198c64bce1daa6372f;hpb=f526fba8b99f487581a3048d4c0f2cd2d3c1d7c9;p=spider.git diff --git a/perl/Prefix.pm b/perl/Prefix.pm index 10559711..246dbb65 100644 --- a/perl/Prefix.pm +++ b/perl/Prefix.pm @@ -363,6 +363,37 @@ L1: for ($n = 0; $n < @parts; $n++) { return @out; } +# +# turn a list of prefixes / dxcc numbers into a list of dxcc/itu/zone numbers +# +# nc = dxcc +# ni = itu +# nz = zone +# + +sub to_ciz +{ + my $cmd = shift; + my @out; + + foreach my $v (@_) { + if ($v =~ /^\d+$/) { + push @out, $v unless grep $_ eq $v, @out; + } else { + my @pre = Prefix::extract($v); + return () unless @pre; + shift @pre; + foreach my $p (@pre) { + my $n = $p->dxcc if $cmd eq 'nc' ; + $n = $p->itu if $cmd eq 'ni' ; + $n = $p->cq if $cmd eq 'nz' ; + push @out, $n unless grep $_ eq $n, @out; + } + } + } + return @out; +} + my %valid = ( lat => '0,Latitude,slat', long => '0,Longitude,slong',