4 use Time::HiRes qw/time/;
12 my ($userid,$sourceid,$rec_id,$entry_file,$id_tag) = (1,2,1,'marc_update.sql','//*[@tag="035"][1]');
15 "sourceid" => \$sourceid,
16 "sql_output=s" => \$entry_file,
17 "userid=i" => \$userid,
18 "first=i" => \$rec_id,
19 "id_tag_xpath=s" => \$id_tag,
24 open RE, ">$entry_file" or die "Can't open $entry_file! $!\n";
32 my $parser = XML::LibXML->new;
35 while ( $xml .= <STDIN> ) {
42 my $doc = $parser->parse_string($xml);;
43 my @nodes = $doc->documentElement->findnodes( $id_tag );
45 $tcn .= $n->textContent;
47 $tcn =~ s/^\s*(\.+)\s*/$1/o;
60 $tcn =~ s/^.*?(\w+)\s*$/$1/go;
63 warn "\nNo TCN found for rec # $rec_id\n";
69 if (exists($$tcn_map{$tcn})) {
70 warn "\n !! TCN $tcn already exists!\n";
76 $$tcn_map{$tcn} = $rec_id;
78 print RE "UPDATE biblio.record_entry SET marc = E'$xml' where id = $rec_id;\n";