# Always
use warnings;
use strict;
use CGI;
my $q = CGI::new;
my %lineitem;
my %ship;
# process params
#
for my $param ( $q->param ) {
my @id = split(/~/,$param);
# a SWITCH would work nicely, but I'll try
# not to confuse the example
if ( $id[0] eq 'item' ) {
$lineitem{$id[1]}{$id[2]} = $q->param($param);
}
if ( $id[0] eq 'ship' ) {
$ship{$id[1]} = $q->param($param);
}
}
# process lineitems
#
print "Please confirm order of
";
for my $item ( keys %lineitem ) {
print $lineitem{$item}{qty},
$lineitem{$item}{name};
print "
";
}
print "
being shipped to $ship{firstname}
";