Webmin / MySQL / DBD::mysql - undefined variable Perl error.
Posted: Fri Oct 31, 2003 2:07 pm
I recently upgraded to the latest Perl module of DBD::mysql (2.9002). After having done so, I discovered that I was unable to access the "Permission" sub-modules of Webmin's MySQL interface. When trying to do so, I got some kind of error message involving Perl, a hash, and not being able to use an undefined variable on line 113 of /usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi/DBD/mysql.pm.
After trying to reinstall the Perl module to no better effect, I finally stumbled onto the solution. Here's what that section of code, from that file, looks like:
Line 113 is the line that starts "$privateAttrHash". I have only a general idea of what this bit of code means (I know it's a way of defining an array variable with information about the database that's being accessed). However, when trying to troubleshoot "undefined variable" that one thing that stood out was the "(undef, $attrhash)" section of code. "Undef", to me, read a lot like "undefined".
So, I tried the trial and error method of replacing "undef" with "def" - thinking, in a very uneducated, shot in the dark fashion, that this might actually define the variable. To my total amazement this actually worked. After having done that, Webmin works just fine when I use the "Permission" sub-modules.
I'm left wondering why the latest version of module would, by default, do something so silly as to declare a variable without defining it, and causing other things to break. I'm equally confused that this would even be a possibility - if you declare a variable you should, by default, be defining it - shouldn't you?
After trying to reinstall the Perl module to no better effect, I finally stumbled onto the solution. Here's what that section of code, from that file, looks like:
Code: Select all
# create a 'blank' dbh
my($this, $privateAttrHash) = (undef, $attrhash);
$privateAttrHash = { %$privateAttrHash,
'Name' => $dsn,
'user' => $username,
'password' => $password
};
So, I tried the trial and error method of replacing "undef" with "def" - thinking, in a very uneducated, shot in the dark fashion, that this might actually define the variable. To my total amazement this actually worked. After having done that, Webmin works just fine when I use the "Permission" sub-modules.
I'm left wondering why the latest version of module would, by default, do something so silly as to declare a variable without defining it, and causing other things to break. I'm equally confused that this would even be a possibility - if you declare a variable you should, by default, be defining it - shouldn't you?