Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to check Itemprice (it should be decimal not alphabet)

Status
Not open for further replies.

neoeasy

Programmer
Feb 12, 2003
1
TH
Hi
I try to check the item price that user enter must be in decimal format

I search to internat and find this script
----------------------------------------------------------
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;
$value =~ s/,//;
-----------------------------------------------------------
but it still don't work perfectly cos if I enter 40.5a it's still accept.

Is the code is right? thanks
 
The line:

$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(&quot;C&quot;, hex($1))/eg;

allows hexidecimal numbers (i.e.: The letters a-f and A-F). Depending on how the rest of your code works, you might be able to remove this line, or you might need to edit it. Unix Sys Admin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top