use strict; use DBI; my $dsn = "DBI:mysql:database=numbers;host=localhost"; my $dbh = DBI->connect($dsn, 'user', 'password'); ## Instead of using '*', use the column names. That way, if ever you ALTER the table this will still work. my $sth = $dbh->prepare("SELECT name, phone1, phone2 FROM numbers"); $sth->execute(); $sth->bind_columns(\my($name,$phone1,$phone2)); while ($sth->fetch()) { print "The name field $name\n"; print "The phone1 field $phone1\n"; print "The phone2 field $phone2\n"; }