Solved

Formatting a number being displayed

Posted on 2004-10-04
3
168 Views
Last Modified: 2013-12-25
I am customising a script and I have not really used perl/cgi before. I have a price which is displayed. The code looks like:

<td>Total Price</td>
  <td><b>UK£ $price</b>

If $Price is 10.46, it is displayed correctly but if $Price is 10.40 it is displayed like 10.4 missing the zero. Any ideas how I can format this number to be displayed correctly everytime.
0
Comment
Question by:joshordan
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
apparition earned 125 total points
Comment Utility
you can try

 sprintf("%10.2f", $price);

http://www.suite101.com/article.cfm/perl/96608
0
 

Author Comment

by:joshordan
Comment Utility
Worked a treat. Many thanks
0
 
LVL 5

Expert Comment

by:apparition
Comment Utility
You are welcome
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now