Solved

Formatting a number being displayed

Posted on 2004-10-04
3
174 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
ID: 12217248
you can try

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

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

Author Comment

by:joshordan
ID: 12219280
Worked a treat. Many thanks
0
 
LVL 5

Expert Comment

by:apparition
ID: 12219304
You are welcome
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

777 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