...making Linux just a little more fun!
By Mark Nielsen
(UPDATE: I ended up passing the MySQL Professional Exam. The examples I made really helped out a lot. Also, I ended up placing my Class::Inheritance module in CPAN under the 06_Data_Type_Utilities/Class category. It's somewhat crude, but it's a good start. I plan on redoing it completely because of some ugly code.)
This module is just in its baby stages. In the future, it should be at http://cpan.perl.com.
How does multiple inheritance work in Perl? Well, when you use inheritance in Perl, you need to create a package. A package is more a less a bunch of functions put together to form a "class" (or multiple classes). A class is more or less a name for a bunch of functions (and sometimes variables). Your class is what is used to create objects in Perl.
So what is inheritance? Let's say you create a package called "package1" and it has a bunch of functions (methods). You want your second package "package2" to have all the functions of the first package but you don't want to rewrite them all. When you use inheritance, that is exactly what you do: you grab all the functions (methods) from the first package and absorb them into the second package without having to rewrite the functions. You do this by specifying the name of the first package in the "@ISA" array.
So what is multiple inheritance? Well, it's what you get when you get your functions from more than one package.
So when you inherit the functions (methods) from multiple packages, how does Perl choose the method if there's more than one with the same name? It grabs the function (method) from the first package in the "@ISA" list which has that function and stops there. Thus, how you list your packages in the "@ISA" list will determine which packages get looked at first to find a function.
By the way, what is a method? A function that is part of a class.
Where is this @ISA thingy defined? It is defined in each package. Each package has its own @ISA list. It is effectively empty if you don't do anything to it. If you define it to contain any number of package names, your package will inherit methods from those packages.
If I have a huge chain of packages inheriting from one another, will the last package get all the functions (methods) from its parents, grandparents, great grandparents, etc? Yes, but it will "climb" up the family tree and stop at the first relative that has the function (method).
For the files listed below, we have two chains relative to package "package6". Package6 contains two packages it inherits from: package5 and package5_2. Each of these packages inherits from package4, which inherits from package3, which inherits from package2, which inherits from package1, which inherits from CGI.
The whole goal of the script "Inherit_Test.pl" is to show the family tree of the package "package6" and to show where package6 gets the method "param" from. You can modify it to suit your own needs.
Download all the files below and then execute "perl Inherit_Test.pl package6 param". You can change "package6" to any package name and you can change "param" to any function name. It will error out properly if no package or function exists.
Try the following:
perl Inherit_Test.pl package6 param perl Inherit_Test.pl package4 param
The expected results for "perl Inherit_Test.pl package4 param":
We assume the filename for the package is in 'package4.pm'. Looking at the function (method) 'param' in class 'package4', we learn that function 'param' comes from class 'CGI'. Parent Tree is: package3 package2 package1 CGI Original sources (defined) for 'param' are: CGI
The expected results for "perl Inherit_Test.pl package6 param":
We assume the filename for the package is in 'package6.pm'. Looking at function (method) 'param' in class 'package6'. Function 'param' comes from the class 'package5'. Parent Tree is: package5 package4 package3 package2 package1 CGI package5_2 package4 package3 package2 package1 CGI Original sources (defined) for 'param' are: package5 CGI package5_2 CGIHere are a list of files you need to save.
# NEW FILE: ### Save this as /usr/local/RealPlayer8/realplay.bat /usr/local/RealPlayer8/realplay.py /usr/local/RealPlayer8/realplay /tmp/temp1.smil
Getting MySQL-certified now is good because there aren't that many people listed. After you pass an exam, it might take a couple of weeks before you get publicly listed. After you pass your exam, you need to log in and let people view which exams you have passed. You find the list of the MySQL Professionals here.
I highly recommend you get the study guide from MySQL Press; it's a good book. Usually certification books contain a lot of garbage, but this one is actually very useful (in my opinion).
After you have passed the Core Certification and you are ready for the Professional Certification, you should execute the scripts I list below. The "Compile_MySQL.bat" script is just a bash script. It will blow away any previous installation in case you want to run the script multiple times. The "Post_Mysql.py" script will create a log of all the commands it executes so that you can go back and do them one-by-one on your own. It would take too long to explain what each command does, so I strongly advise you to read the online MySQL Documentation or the study guide to understand what each command does.
The script should execute as long as you don't have any missing software.
First, download the 3 config
files and then download this script. Execute the script as follows:
This script will alter the MySQL environment. It will run a series of example commands and restart the MySQL service which will require you to use the new passwords when you try and connect to MySQL in the future. I suggest you change the passwords for all accounts after you get done with this script.
After you run this script, you can connect as:
mysql -u root -p'this is a dumb password, please change.'
Execute as follows:
python Post_Mysql.py /usr/local/mysql4.1
About the Python script to play mp3s, I hope this little script helps people understand how to use Python. Python is a very cool programming language and is my language of choice. It has a lot of potential.
About the MySQL scripts: I probably should have explained the MySQL commands a little bit more in detail, but if you buy the book or read the online documentation, you should be able to understand it. If you manage to execute my scripts correctly, look at the log files in the Output directory from where you run the Post_Mysql.py script. It should have a couple of files with all the commands it executed so that you can go through them one by one. Ideally, you should execute the commands one by one and see what they do. You should also follow along in the study guide for MySQL (MySQL Press) as you do so.
Mark Nielsen was enjoying his work at cnet.com as a MySQL DBA, but
is moving to Google as a MySQL DBA.
During his spare time, he uses Python heavily for mathematical and web