adding some basic copy tag and serial tables to the mig init function
[migration-tools.git] / extract_loadset
index 43b2e52..61326bd 100755 (executable)
@@ -41,7 +41,12 @@ open MI, '<', $conf->{input} or die "Can't open input file: $!\n";
 open MO, '>', $conf->{output} or die "Can't open output file: $!\n";
 while (<MI>) {
     m/tag="$conf->{tag}".+?<subfield code="$conf->{subfield}">(\d+)</;
-    print MO unless $exclude{$1};
+    next unless defined $1;
+    if ($conf->{reverse}) {
+        print MO if     $exclude{$1};
+    } else {
+        print MO unless $exclude{$1};
+    }
 }
 
 
@@ -58,6 +63,7 @@ sub initialize {
                          'output|o=s',
                          'tag|t=i',
                          'subfield|s=s',
+                         'reverse|r',
                          'help|h',
                        );
     show_help() unless $rc;
@@ -85,6 +91,7 @@ Usage is: extract_loadset -l BOUND -i INPUTXML -o OUTPUTXML MATCHSET
   --output      -o  MARCXML output file
   --tag         -t  MARC tag to use as identifier (default: 903)
   --subfield    -s  Subfield of --tag argument (default: 'a')
+  --reverse     -r  Output subordinate bibs rather than lead bibs
 HELP
 exit;
 }