Now you can redesign your original Checking.pm module to use the MySQL database rather than the text file you originally created to keep track of the balance.
Create the database and the register table at the mysql prompt. This register should contain fields that match the text file called "register" you created in the first exercise.
In the Perl module, Checking.pm, open the connection to the database. To get the balance, you will select it from the "register" table.
When you call your exit() function, insert the last transaction into the database with the new information, using the SQL INSERT command.
Create a Perl function that, when called, displays the contents of the register.
You should know how to:
Use PPM and CPAN to install MySQL, DBI, and the database driver.
Issue basic MySQL commands.
Connect to the database server from a Perl script.
Use Perl MySQL functions to:
Select a database Prepare and execute SQL statements Use DBI methods to iterate through the result set Use placeholders Bind columns and parameters Check for errors generated by the database server Keep track of the number of records retrieved Discard the planned query Disconnect from the database from a Perl script
|