Bug 21395: Make perlcritic happy
[srvgit] / misc / migration_tools / 22_to_30 / export_Authorities_xml.pl
index 70647ee..c8a5aa9 100755 (executable)
@@ -1,6 +1,5 @@
 #!/usr/bin/perl
-#use strict;
-#use warnings; FIXME - Bug 2505
+use Modern::Perl;
 BEGIN {
     # find Koha's Perl modules
     # test carefully before changing this
@@ -23,7 +22,7 @@ $rq->execute;
 #ATTENTION : Mettre la base en utf8 auparavant.
 #BEWARE : Set database into utf8 before.
 while (my ($authid)=$rq->fetchrow){
-open FILEOUTPUT,">:utf8", "./$filename/$authid.xml" or die "unable to open $filename";
+open my $fileoutput, '>:encoding(UTF-8)', "./$filename/$authid.xml" or die "unable to open $filename";
   my $record=AUTHgetauthority($dbh,$authid);
   if (! utf8::is_utf8($record)) {
     utf8::decode($record);
@@ -31,7 +30,7 @@ open FILEOUTPUT,">:utf8", "./$filename/$authid.xml" or die "unable to open $file
                        
 #  if (C4::Context->preference('marcflavour') eq "UNIMARC"){
        $record->leader('     nac  22     1u 4500');
-    my $string=$1 if $time=~m/([0-9\-]+)/;
+    my $string = ($time=~m/([0-9\-]+)/) ? $1 : undef
     $string=~s/\-//g;
      $string = sprintf("%-*s",26, $string);
      substr($string,9,6,"frey50");
@@ -44,7 +43,7 @@ open FILEOUTPUT,">:utf8", "./$filename/$authid.xml" or die "unable to open $file
      # } else {
 #    $record->encoding( 'UTF-8' );
 #  }
-  print FILEOUTPUT $record->as_xml();
-close FILEOUPUT;
+  print {$fileoutput}  $record->as_xml();
+close $fileoutput;
 
 }