[Koha-patches] [PATCH] Cleanup and perltidy.

Joe Atzberger joe.atzberger at liblime.com
Wed Jan 28 20:25:48 CET 2009


Add "use warnings", remove unused variables and unnecessary finish/disconnect
at the end.  This script could be improved to run only on tables that need to
be altered instead of touching all of them.  It should also probably contain
warnings to the effect that it does not rescue your DATA that was forced into
whatever encoding the table used previously.
---
 misc/migration_tools/22_to_30/convert_to_utf8.pl |   21 +++++++++------------
 1 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/misc/migration_tools/22_to_30/convert_to_utf8.pl b/misc/migration_tools/22_to_30/convert_to_utf8.pl
index bad4b96..fbbff89 100755
--- a/misc/migration_tools/22_to_30/convert_to_utf8.pl
+++ b/misc/migration_tools/22_to_30/convert_to_utf8.pl
@@ -3,27 +3,24 @@
 # small script to convert mysql tables to utf-8
 
 use strict;
+use warnings;
+
 BEGIN {
+
     # find Koha's Perl modules
     # test carefully before changing this
     use FindBin;
     eval { require "$FindBin::Bin/../../kohalib.pl" };
 }
-use C4::Context;
 
-my $dbh=C4::Context->dbh();
-
-my $database=C4::Context->config("database");
-my $query="Show tables";
-my $sth=$dbh->prepare($query);
+use C4::Context;
+my $dbh = C4::Context->dbh();
+my $sth = $dbh->prepare("Show tables");
 $sth->execute();
-while (my @table=$sth->fetchrow_array()){
+while (my @table = $sth->fetchrow_array()) {
     print "Altering table $table[0]\n";
-    my $alter_query="ALTER TABLE $table[0] convert to CHARACTER SET UTF8 collate utf8_general_ci";
-    my $sth2=$dbh->prepare($alter_query);
+    my $alter_query = "ALTER TABLE $table[0] convert to CHARACTER SET UTF8 collate utf8_general_ci";
+    my $sth2        = $dbh->prepare($alter_query);
     $sth2->execute();
     $sth2->finish();
-
 }
-$sth->finish();
-$dbh->disconnect();
-- 
1.5.5.GIT



More information about the Koha-patches mailing list