Code: Perl
my $insert = qq~ insert into cart (id,cat_num) select id,catalog_num from tracks where id =?~;
my $dbh    = DBI->connect( $connectionInfo, $user, $passwd );
my $sth    = $dbh->prepare($insert);

foreach ( $cgi_object->param() ) {
    $form{$_} = $cgi_object->param($_);
    $catnum   = $form{cat_num};
    $row      = $form{id};

    $sth->execute($row);
}