[thelist] Perl program question

MILLER David R. dmiller at mcc.ca
Fri Jun 9 13:06:22 CDT 2006


I don't have time to figure out exactly what you're doing with this
script, and there are some weird ways you're doing things, but what you
want to do is get this up and running.

The line
$arg =~ m/(\d+\.\d{2})/;
presumably snags the total from the query string. The parentheses in the
regexp will put the captured value TEMPORARILY in $1. You rely on $1
later in the script to represent the total, and I think that's the crux
of your problem.

Try changing the line above to
my ($total) = $arg =~ m/(\d+\.\d{2})/;
and then using $total instead of $1 in your calculations and elsewhere.

BTW, I belive you could just use 
my $total = $q->param('total');
to retrieve the total, which would be more reliable.

-----------------------------------------
David R. Miller
-----------------------------------------

Original message:

Message: 1
Date: Fri, 09 Jun 2006 12:49:38 -0400
From: Portman <mrport at sbcglobal.net>
Subject: [thelist] Perl program question
To: "thelist at lists.evolt.org" <thelist at lists.evolt.org>
Message-ID: <4489A6A2.4080801 at sbcglobal.net>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Hi,

I wrote a Perl program for a client a while ago and she recently called 
me to say that it is not calculating the shipping correctly.  The 
shipping is calculated by taking a percentage of the total (depending on

location) plus a $5 shipping and handling fee. I wrote the program so 
that the person would only be able to return to the cart after choosing 
a state and clicking calculate. I have been through the code over and 
over and cannot figure out what is wrong. If anyone is able to help it 
would be much appreciated.

The script is at http://www.starqualitydesigns.com/blums/ship.cgi and 
can be seen in action at http://www.blumspapergoods.com (add something 
to the shopping cart and go from there). Please remember that this is a 
live site.

Thank you,
Riva




More information about the thelist mailing list