I want numeric, Not string.

How can I convince use CGI qw(:standard) that $price = param("cost") is intended as a number and not a string?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Does it now believe it it not intended as a number?
budginAuthor Commented:
It keeps returning a value of zero.
in the start_html() part of the program, I have (print $price;) and it returns "25", but it wont add it to the cookie.
If I use ($price = 25;) it adds it, but I need it to read a value from another form.
If (print $price;) is really returning with the quotes around the number, then those non-numeric characters would make it have a value of zero when adding.
You could remove all non-digits from $price with something like
$price =~ s/\D//g;
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

budginAuthor Commented:
I thank you very much for your help. I would appreciate it if you would take a look at http://www.budmar.com/budcart.htm  I have links to code in the CGIs.
What are you adding $price to?
Doesn't look to me like $price is the problem at all. Here's what I see:

Problem 1: verify.cgi calls cartx.cgi with the piece to add and the price. cartx.cgi is looking for (param('action') eq 'Add'), and for param('new_items') to contain the items to add. (Both of which are true when cartx.cgi calls itself to edit the cart). You need verify.cgi to use the same fields, or else add code to cartx.cgi to check param('piece') so they are in sync. Since verify.cgi doesn't set an action cartx.cgi doesn't add it. cartx.cgi.

Problem 2: %pce is supposed to holds the number of items, the comment says so -
# The cookie formatted as an associative array
# mapping item name to the number of items.

But then when you add an item $_ to %pce you use:

$pce{$_} = $pce + $price;

Problem 2a: $pce is blank, you meant to use $pce{$_} there.
Problem 2b: Since %pce holds *quantity* not price, you really want
$pce{$_} += $quantity;

What you then need to do is as you print the table, look up the price in cartx.dat and print and total it from there. You certainly don't want to depend on saving the price in a cookie or getting it from a form, since the user could theoretically edit the html to set the price to whatever he wants.

As best I can tell you are setting the cookie and reading it back correctly, the problem is how you set %pce.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
budginAuthor Commented:
Thanks Much to ozo and alamo. I see what I was doing. Without a need for a quanity feature when selling antiques, I was trying to alter that parameter, instead of using gumption. I am starting form scratch, and being patient.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.