September 2002
Intermediate to advanced
544 pages
13h 6m
English
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.
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"; ... |
Read now
Unlock full access