#!/usr/bin/perl #c11ex6.cgi - displays items purchased on a web page use CGI qw(:standard); #prevent Perl from creating undeclared variables use strict; #declare variables my ($rec, @records, $C_records, $basket, @purchases, @items); @items = ("One Pint Square","One Quart Square","One Quart Oblong","Four Quart Square","Four Quart Oblong"); #assign input to variable $basket = param('Basket'); #retrieving cookie @purchases = split(/ /, cookie('cookie')); #adding purchase to cookie push(@purchases, $basket); #create cookie $C_records = cookie(-name => "cookie", -value => "@purchases", -path => "/cgi-bin/c11ex6.cgi"); #send cookie to browser print header(-cookie => $C_records); #create Web page print "\n"; print "Wicker Baskets, Inc.\n"; print "\n"; print "

Wicker Baskets, Inc.


\n"; print "

Your purchases are:


\n"; foreach my $rec (@purchases) { print "$items[$rec]
\n"; } print "\n"; print "\n";