Now that you’ve got a picture of what the relational database looks like, let’s examine the modified catalog.pl program. This program offers the same functionality as the catalog program from Hour 16. It displays the catalogs for users, and process requests to add items to the user’s shopping cart. It differs from the old script in that it opens a database connection instead of creating filehandles, and processes the results of SQL queries instead of parsing files. The source code for the new catalog.pl program appears in Listing 20.3.
1: #!/usr/local/bin/perl 2: 3: use strict; 4: 5: use CGI; 6: use CGI::Carp qw( fatalsToBrowser ); 7: use DBI; 8: 9: my $query = new CGI; 10: 11: ...