You are looking at a very old, but free version of the course. If you are interesed the most recent version, check it out on the Perl Maven site.

13.3. Connect to database

Example 13-1. examples/dbi/connect.pl

#!/usr/bin/perl
use strict;
use warnings;

use DBI;

my $dbfile = "sample.db";

my $dsn = "dbi:SQLite:dbname=$dbfile";
my $dbh = DBI->connect($dsn);



Connecting to other databases:

my $dsn = "DBI:mysql:database=$database;host=$hostname;port=$port";
my $dbh = DBI->connect($dsn, $user, $password);


If you are interested in on-site trainings by the author, please contact me directly.