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 Contents of the Shopping Cart

The cart.pl file is used to view the contents of shopping carts, and to allow users to remove items from the cart if they no longer intend to purchase them. If the script receives no parameters, it just retrieves the list of items in the user’s shopping cart and displays them. Each item in the cart is accompanied by a form that can be used to remove that item from the shopping cart. If the action parameter is set to remove,it attempts to remove the specified item from the cart. The full source code for the script appears in Listing 16.3.

Listing 16.3. The Source Code for cart.pl
 1: #!/usr/local/bin/perl 2: 3: use strict; 4: 5: use CGI; 6: use CGI::Carp qw( fatalsToBrowser ); 7: 8: my $cart_file = "cart.txt"; ...

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