AboutJustin Wheeler Expertise Any question relating to Perl including its internals, data structures, speed, memory usage, syntax, version changes, extra CPAN modules, code standards, code cleanup, or just silly problems.
Experience I have been writing Perl code professionally for almost 10 years. I have modules on CPAN, have Perl code that's included in the latest versions of Redhat, Debian, etc. I have done professional Perl work for many household names including Ticketmaster, Interflora, and allbookstores.com.
Education/Credentials Only work experience and a love of all things Perl.
Question I'm trying to read in name-value pairs from a POST where the value pairs are "CD=2&CD=3&CD=4
I need to be able to multiply the first value times a number and the second value times a different number, etc.
Then I need to provide the user with a total cost of items to purchase.
I seem to be having trouble figuring out how to use the 'split' properly, then do the math and then how to get it to output a page properly.
Thanks in advance for any help you may be able to provide,
Mark
Answer Hi Mark,
Your best bet is to use the CGI script, which will parse it for you.
Then, you'd do something like.
my $q = new CGI;
my @cds = $q->param( 'CD' );
print $q->header();
print "First one multiplied by six is: " . ($cd[0] * 6) . "\n";
print "Second one multiplied by five is: " . ($cd[1] * 5) . "\n";
Or even:
my $q = new CGI;
my @cds = $q->param( 'CD' );
my @multiply_by = qw( 3 7 4 2 6 9 6 43 3 67 8 );