O'Reilly logo

Sams Teach Yourself CGI in 24 Hours, Second Edition by Rafe Colburn

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Catalog Script

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.

Listing 20.3. The Source Code for catalog.pl
 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: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required