$dbh = DBI->connect("DBI:mysql:$database:localhost","$username","$password"); my $sth = $dbh->prepare("SELECT * FROM emails"); $sth->execute(); # iterate through resultset while(my $ref = $sth->fetchrow_hashref()) { print "Email: $ref->{'contest'}\n\n"; } # clean up $dbh->disconnect();