make the major mod to make PC16 the master record for triggering the update
[spider.git] / perl / Filter.pm
index 66c3ff7acb2aceb64b1a1ec1265c2cda8d94bcf3..4443fc5570ac2360d40af67587c5d10f028aeec4 100644 (file)
@@ -92,7 +92,9 @@ sub compile
        my $rr;
        
        if ($ref->{$ar} && exists $ref->{$ar}->{asc}) {
-               $ref->{$ar}->{code} = eval "sub { my \$r=shift; return $ref->{$ar}->{asc}; }" ;
+               my $s = $ref->{$ar}->{asc};     # an optimisation?
+               $s =~ s/\$r/\$_[0]/g;
+               $ref->{$ar}->{code} = eval "sub { $s }" ;
                if ($@) {
                        my $sort = $ref->{sort};
                        my $name = $ref->{name};
@@ -494,6 +496,11 @@ sub parse
                                                        my @pre = Prefix::to_ciz($cmd, @val);
                                                        return ('numpre', $dxchan->msg('e27', $_)) unless @pre;
                                                        $s .= "(" . join(' || ', map {"\$r->[$fref->[2]]==$_"} @pre) . ")";
+                                               } elsif ($fref->[1] =~ /^ns$/ ) {    # for DXCC, ITU, CQ Zone    
+                                                       my $cmd = $fref->[1];
+                                                       my @pre = Prefix::to_ciz($cmd, @val);
+                                                       return ('numpre', $dxchan->msg('e27', $_)) unless @pre;
+                                                       $s .= "(" . "!\$USDB::present || grep \$r->[$fref->[2]] eq \$_, qw(" . join(' ' ,map {uc} @pre) . "))";
                                                } elsif ($fref->[1] eq 'r') {
                                                        my @t;
                                                        for (@val) {