while (my $ref = $sth->SOMETING HERE) { print "The name field " . $ref[name]; print "The phone1 field " . $ref[phone1]; print "The phone2 field " . $ref[phone2]; }