pre 1.13 release
[spider.git] / perl / Prefix.pm
index d4ed48b33dbcf0fa7e8fd8e6daf9339c53cae900..cab54cd80b1f32c1ed46367c7eb609c477cbf358 100644 (file)
@@ -12,13 +12,14 @@ use Carp;
 use DXVars;
 use DB_File;
 use Data::Dumper;
+use Carp;
 
 use strict;
 use vars qw($db  %prefix_loc %pre);
 
-local $db;     # the DB_File handle
-local %prefix_loc;   # the meat of the info
-local %pre;       # the prefix list
+$db = undef;     # the DB_File handle
+%prefix_loc = ();   # the meat of the info
+%pre = ();       # the prefix list
 
 sub load
 {
@@ -28,9 +29,11 @@ sub load
        %prefix_loc = ();
   }
   $db = tie(%pre, "DB_File", undef, O_RDWR|O_CREAT, 0666, $DB_BTREE) or confess "can't tie \%pre ($!)";  
-  confess $@ if $@;
-  do "$main::data/prefix_data.pl";
+  my $out = $@ if $@;
+  do "$main::data/prefix_data.pl" if !$out;
+  $out = $@ if $@;
 #  print Data::Dumper->Dump([\%pre, \%prefix_loc], [qw(pre prefix_loc)]);
+  return $out;
 }
 
 sub store
@@ -145,9 +148,9 @@ sub extract
   # remove any /0-9 /P /A /M /MM /AM suffixes etc
   if (@parts > 1) {
     $p = $parts[$#parts];
-       pop @parts if $p =~ /^\d+|[PABM]|AM|MM|BCN|SIX$/o;
+       pop @parts if $p =~ /^(\d+|[PABM]|AM|MM|BCN|SIX|Q\w+)$/o;
     $p = $parts[$#parts];
-       pop @parts if $p =~ /^\d+|[PABM]|AM|MM|BCN|SIX$/o;
+       pop @parts if $p =~ /^(\d+|[PABM]|AM|MM|BCN|SIX|Q\w+)$/o;
   
     # can we resolve them by direct lookup
        foreach $p (@parts) {