get all the debugging finally into the debug files when things go wrong
[spider.git] / perl / Prefix.pm
index ba9ea2b93c1f91fa5a4530f7ba6f4025a7c6d667..41a95db8086ec106eec66a102ecda92324727497 100644 (file)
@@ -8,11 +8,11 @@
 
 package Prefix;
 
-use Carp;
+use IO::File;
 use DXVars;
 use DB_File;
 use Data::Dumper;
-use Carp;
+use DXDebug;
 
 use strict;
 use vars qw($db  %prefix_loc %pre);
@@ -24,6 +24,7 @@ $db = undef;                                  # the DB_File handle
 sub load
 {
        if ($db) {
+               undef $db;
                untie %pre;
                %pre = ();
                %prefix_loc = ();
@@ -39,7 +40,7 @@ sub load
 sub store
 {
        my ($k, $l);
-       my $fh = new FileHandle;
+       my $fh = new IO::File;
        my $fn = "$main::data/prefix_data.pl";
   
        confess "Prefix system not started" if !$db;
@@ -76,7 +77,8 @@ sub store
                $fh->print("$str ],\n");
        }
        $fh->print(");\n");
-       $fh->close;
+       undef $fh;
+       untie %pre; 
 }
 
 # what you get is a list that looks like:-
@@ -147,10 +149,12 @@ sub extract
 
        # remove any /0-9 /P /A /M /MM /AM suffixes etc
        if (@parts > 1) {
+               $p = $parts[0];
+               shift @parts if $p =~ /^(WEB|NET)$/o;
                $p = $parts[$#parts];
-               pop @parts if $p =~ /^(\d+|[PABM]|AM|MM|BCN|SIX|Q\w+)$/o;
+               pop @parts if $p =~ /^(\d+|[PABM]|AM|MM|BCN|SIX|WEB|NET|Q\w+)$/o;
                $p = $parts[$#parts];
-               pop @parts if $p =~ /^(\d+|[PABM]|AM|MM|BCN|SIX|Q\w+)$/o;
+               pop @parts if $p =~ /^(\d+|[PABM]|AM|MM|BCN|SIX|WEB|NET|Q\w+)$/o;
   
                # can we resolve them by direct lookup
                foreach $p (@parts) {