]> git.donarmstrong.com Git - infobot.git/blobdiff - src/Files.pl
avoid reassigning to temp upon decode_utf8
[infobot.git] / src / Files.pl
index b302604d09a46c2b4e6f1bf4c4cae764a3ca86f9..3a294aae063c628a2fd3fb8c1c7eb23690cbf99a 100644 (file)
@@ -5,7 +5,11 @@
 #  Created: 19991221
 #
 
-if (&IsParam("useStrict")) { use strict; }
+use strict;
+
+use vars qw(%lang %ircPort);
+use vars qw(@ircServers);
+use vars qw($bot_config_dir);
 
 # File: Language support.
 sub loadLang {
@@ -13,67 +17,70 @@ sub loadLang {
     my $langCount = 0;
     my $replyName;
 
-    if (!open(FILE, $file)) {
-       &ERROR("FAILED loadLang ($file): $!");
-       exit 0;
+    if ( !open( FILE, $file ) ) {
+        &ERROR("Failed reading lang file ($file): $!");
+        exit 0;
     }
 
-    undef %lang;               # for rehash.
+    undef %lang;    # for rehash.
 
     while (<FILE>) {
-       chop;
-       if ($_ eq "" || /^#/) {
-           undef $replyName;
-           next;
-       }
-
-       if (!/^\s/) {
-           $replyName = $_;
-           next;
-       }
-
-       s/^[\s\t]+//g;
-       if (!$replyName) {
-           &status("loadLang: bad line ('$_')");
-           next;
-       }
-
-       $lang{$replyName}{$_} = 1;
-       $langCount++;
+        chop;
+        if ( $_ eq '' || /^#/ ) {
+            undef $replyName;
+            next;
+        }
+
+        if ( !/^\s/ ) {
+            $replyName = $_;
+            next;
+        }
+
+        s/^[\s\t]+//g;
+        if ( !$replyName ) {
+            &status("loadLang: bad line ('$_')");
+            next;
+        }
+
+        $lang{$replyName}{$_} = 1;
+        $langCount++;
     }
     close FILE;
 
     $file =~ s/^.*\///;
-    &status("Loaded lang $file ($langCount items)");
+    &status("Loaded $file ($langCount items)");
 }
 
 # File: Irc Servers list.
 sub loadIRCServers {
-    my ($file) = $bot_config_dir."/ircII.servers";
+    my ($file) = $bot_config_dir . '/infobot.servers';
     @ircServers = ();
-    %ircPort = ();
+    %ircPort    = ();
 
-    if (!open(FILE, $file)) {
-       &ERROR("FAILED loadIRCServers ($file): $!");
-       exit 0;
+    if ( !open( FILE, $file ) ) {
+        &ERROR("Failed reading server list ($file): $!");
+        exit 0;
     }
 
     while (<FILE>) {
-       chop;
-       next if /^\s*$/;
-       next if /^[\#\[ ]/;
-
-       if (/^(\S+)(:(\d+))?$/) {
-           push(@ircServers,$1);
-           $ircPort{$1} = ($3 || 6667);
-       } else {
-           &status("loadIRCServers: invalid line => '$_'.");
-       }
+        chop;
+        next if /^\s*$/;
+        next if /^[\#\[ ]/;
+
+        if (/^\s*(\S+?)(:(\d+))?\s*$/) {
+            push( @ircServers, $1 );
+            $ircPort{$1} = ( $3 || 6667 );
+        }
+        else {
+            &status("loadIRCServers: invalid line => '$_'.");
+        }
     }
     close FILE;
 
     $file =~ s/^.*\///;
-    &status("Loaded ircServers $file (". scalar(@ircServers) ." servers)");
+    &status( "Loaded $file (" . scalar(@ircServers) . ' servers)' );
 }
 
 1;
+
+# vim:ts=4:sw=4:expandtab:tw=80