#!/usr/bin/perl

use warnings;
use strict;

use DBI;

my $dbhandle = DBI->connect(
    'dbi:Pg:dbname=address',
    '',
    '',
    { AutoCommit => 1 }
);

my $statement = $dbhandle->prepare( 'select id, first, last, email from names' );
$statement->execute;

while ( my $row_ref = $statement->fetchrow_hashref() ) {
    printf( "% 5d %-20s %-20s %-30s\n",
        $row_ref->{'id'},
        $row_ref->{'first'},
        $row_ref->{'last'},
        $row_ref->{'email'}
    );
}



