4 use MARC::File::XML(BinaryEncoding=>"utf8");
5 use C4::AuthoritiesMarc;
7 MARC::File::XML::default_record_format("UNIMARCAUTH");
8 my $dbh = C4::Context->dbh;
9 my $rq= $dbh->prepare(qq|
13 my $filename= shift @ARGV;
15 #ATTENTION : Mettre la base en utf8 auparavant.
16 #BEWARE : Set database into utf8 before.
17 while (my ($authid)=$rq->fetchrow){
18 open my $fileoutput, '>:encoding(UTF-8)', "./$filename/$authid.xml" or die "unable to open $filename";
19 my $record=AUTHgetauthority($dbh,$authid);
20 if (! utf8::is_utf8($record)) {
21 utf8::decode($record);
24 # if (C4::Context->preference('marcflavour') eq "UNIMARC"){
25 $record->leader(' nac 22 1u 4500');
26 my @time = localtime(time);
27 my $time = sprintf('%04d%02d%02d', $time[5] + 1900, $time[4] + 1, $time[3]);
28 my $string = ($time=~m/([0-9\-]+)/) ? $1 : undef;
30 $string = sprintf("%-*s",26, $string);
31 substr($string,9,6,"frey50");
32 unless ($record->subfield(100,"a")){
33 $record->insert_fields_ordered(MARC::Field->new(100,"","","a"=>$string));
35 unless ($record->subfield('001')){
36 $record->insert_fields_ordered(MARC::Field->new('001',$authid));
39 # $record->encoding( 'UTF-8' );
41 print {$fileoutput} $record->as_xml();