#!/usr/bin/perl -w use strict; use DBI(); my $dbh = DBI->connect( "DBI:mysql:database=mydb;host=localhost", "mywebuser", "mypassword", { 'RaiseError' => 1 } ); my $sth = $dbh->prepare( "SELECT * from mytable;" ); $sth->execute(); while ( my $ref = $sth->fetchrow_hashref() ) { print "Found a row: id = $ref->{ 'id' }, name = $ref->{ 'name' }\n"; } $sth->finish(); $dbh->disconnect;