use DBI; $dbh = DBI->connect('DBI:mysql:accounts:localhost','user','password') || die("Couldn't connect to server"); $sth = $dbh->prepare('select name,balance from active where balance > 100;'); $sth->execute(); while((@row) = $sth->fetchrow()){ print "$row[0] $row[1]\n"; }