]> git.99rst.org Git - irssi-scripts.irssi.org.git/commitdiff
array returns from glob and wrong filehandle
authorEremita Solitario <redacted>
Tue, 24 May 2022 19:54:06 +0000 (21:54 +0200)
committerEremita Solitario <redacted>
Tue, 24 May 2022 19:54:06 +0000 (21:54 +0200)
Patched the code to solve two little bugs:
- corrected glob as it returns an array and not a single value
- corrected wrong filehandle name when closing file

scripts/randname.pl

index 388a78b4551f671e1c10588e959baac2244f038f..df5ae360d6fde46cef76b47fe2ab22252566ca37 100644 (file)
@@ -1,4 +1,4 @@
-# RandName 1.0
+# RandName 1.1
 # 
 # set a random real name taken from a file
 # 
@@ -8,7 +8,7 @@ use strict;
 use Irssi;
 use vars qw($VERSION %IRSSI);
 
-$VERSION = '1.0';
+$VERSION = '1.1';
 %IRSSI = (
         authors         => 'legion',
        contact         => 'a.lepore(at)email.it',
@@ -20,7 +20,7 @@ $VERSION = '1.0';
 
 sub randname {
 
-       my $namefile = glob Irssi::settings_get_str('random_realname_file');
+       my $namefile = (glob Irssi::settings_get_str('random_realname_file'))[0];
 
        open (FILE, "<", $namefile) || return;
        my $lines = 0; while(<FILE>) { $lines++; };
@@ -34,7 +34,7 @@ sub randname {
                $realname = $_;
                last;
        }
-       close(f);
+       close(FILE);
        
        Irssi::print("%9RandName.pl%_:", MSGLEVEL_CRAP);
        Irssi::command("set real_name $realname");
git clone https://git.99rst.org/PROJECT