]> dxcluster.org Git - spider.git/commitdiff
try ALL the parts of fr5dx/t
authorminima <minima>
Thu, 4 Jul 2002 15:44:41 +0000 (15:44 +0000)
committerminima <minima>
Thu, 4 Jul 2002 15:44:41 +0000 (15:44 +0000)
perl/Prefix.pm

index 17ba83dca5b7ea6711c7b87fdbd2ce6f27e197ce..a08f5a4498820e124ef3145743fab9ab2c560439 100644 (file)
@@ -180,26 +180,32 @@ sub extract
   
                # which is the shortest part (first if equal)?
                dbg("Parts: $call = " . join('|', @parts))      if isdbg('prefix');
-               $sp = $parts[0];
-               foreach $p (@parts) {
-                       $sp = $p if length $p < length $sp;
-               }
-               $sp =~ s/-\d+$//;     # remove any SSID
                
-#              # now start to resolve it from the left hand end
-#              for ($i = 1; $i <= length $sp; ++$i) {
-               # now start to resolve it from the right hand end
-               for ($i = length $sp; $i >= 1; --$i) {
-                       my $ssp = substr($sp, 0, $i);
-                       my @wout = get($ssp);
-                       if (isdbg('prefix')) {
-                               my $part = $wout[0] || "*";
-                               dbg("Partial prefix: $sp $ssp $part" );
-                       } 
-                       next if @wout > 0 && $wout[0] gt $ssp;
-#                      last if @wout == 0;
-                       push @out, @wout;
-                       last if @wout;
+               # try ALL the parts
+L1:            for (;@parts;) {
+                       $sp = $parts[0];
+                       foreach $p (@parts) {
+                               $sp = $p if length $p < length $sp;
+                       }
+                       @parts = grep { $_ ne $sp } @parts;     # remove it from the list
+                       $sp =~ s/-\d+$//;     # remove any SSID
+                       
+                       #               # now start to resolve it from the left hand end
+                       #               for ($i = 1; $i <= length $sp; ++$i) {
+                       # now start to resolve it from the right hand end
+                       for ($i = length $sp; $i >= 1; --$i) {
+                               my $ssp = substr($sp, 0, $i);
+                               my @wout = get($ssp);
+                               if (isdbg('prefix')) {
+                                       my $part = $wout[0] || "*";
+                                       $part .= '*' unless $part eq '*' || $part eq $ssp;
+                                       dbg("Partial prefix: $sp $ssp $part" );
+                               } 
+                               next if @wout > 0 && $wout[0] gt $ssp;
+                               #                       last if @wout == 0;
+                               push @out, @wout;
+                               last L1 if @wout;
+                       }
                }
        }
        if (isdbg('prefix')) {