# Collection of code snippets by Arne Vajhøj 
# (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
use DBI;
# connect
my $con = DBI->connect('DBI:mysql:host=localhost:database=Test','','') or die DBI->errstr;
# display all rows
my $stmt = $con->prepare('SELECT * FROM t1') or die $con->errstr;
$stmt->execute;
while(@row = $stmt->fetchrow_array()) {
    my $f1 = $row[0];
    my $f2 = $row[1];
    print "$f1 $f2\n";
}
# insert new row
my $stmt = $con->prepare('INSERT INTO t1 VALUES(?,?)') or die $con->errstr;
$stmt->execute(6,'FFFFFF');
# display all rows again
my $stmt = $con->prepare('SELECT * FROM t1') or die $con->errstr;
$stmt->execute;
while(@row = $stmt->fetchrow_array()) {
    my $f1 = $row[0];
    my $f2 = $row[1];
    print "$f1 $f2\n";
}
# disconnect
$con->disconnect;
