Every Perl script that uses the DBI module must include the following line:
It's not necessary to include a use line for a particular DBD-level module because DBI will take care of activating the proper module when you connect to the server.
Normally, a DBI script opens a connection to a MySQL server using the connect() method and closes the connection with disconnect(). While the connection is open, queries can be issued. The methods used to execute queries vary, depending on the type of statement. Non-SELECT queries typically are performed with the do() method. SELECT queries typically are performed by passing the query to prepare(), calling execute(), and finally retrieving query results a row at a time in a loop that repeatedly invokes a row-fetching method, such as fetchrow_array() or fetchrow_hashref().
When you issue queries from within a DBI script, each query string must consist of a single SQL statement and should not end with a semicolon character (';') or a \g sequence. ';' and \g are conventions of the mysql client program and are not used for DBI.