Listing 3-1 contains the complete and uninterrupted code from this chapter's program example.
Listing 3-1: Table Add
01: #!/usr/bin/perl -w 02: # add_table.pl 03: # Chapter 3 04: # Listing 1 05: use strict; 06: use DBI; 07: my $dbh = DBI->connect("DBI:mysql:widgets", "bookuser","testpass") 08: or die("Cannot connect: $DBI::errstr\n"); 09: my $sql = qq{CREATE TABLE products ( 10: Pid INT NOT NULL, 11: Item VARCHAR(255), 12: Descr VARCHAR(255), 13: Price REAL, 14: Vid INT NOT NULL)}; 15: my $return = $dbh->do($sql); 16: if($return) { 17: print "Table addition successful!\n"; 18: } 19: else { 20: print "\n\nERROR! $DBI::errstr\n"; 21: }