http://www.perlmonks.org?node_id=122638

Zecho has asked for the wisdom of the Perl Monks concerning the following question:

Ok, DBI & MySQL are kickin my butt right now, I've read what tutorials and documentation I could find (and those pointed out to me in the CB) and am really looking for a simple solution for this. Someone please tell me there's a cleaner/easier way to simply add a row to the table.

What I've hacked together so far:

## table customers #|Company #|FirstName #|LastName #|PhoneNumber #|Bill2Street #|Bill2City #|Bill2State #|Bill2Zip #|Ship2Street #|Ship2City #|Ship2State #|Ship2Zip ###### my $dbh = DBI->connect('DBI:mysql:advance') or die "Couldn't connect t +o database: " . DBI->errstr; sub add_customer{ my ($company, $firstname, $lastname, $phonenumber, $bill2street, $bill +2city, $bill2state, $bill2zip, $ship2street, $ship2city, $ship2state, + $ship2zip) = @_; my $sth = $dbh->do('INSERT INTO customers VALUES (?,?,?,?,?,?,?,?,?,?, +?,?)'); die "Couldn't add customer" unless defined $sth; $sth->execute($company, $firstname, $lastname, $phonenumber, $bill2str +eet, $bill2city, $bill2state, $bill2zip, $ship2street, $ship2city, $s +hip2state, $ship2zip); }