• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 180
  • Last Modified:

Formatting a number being displayed

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
joshordan
Asked:
joshordan
  • 2
1 Solution
 
apparitionCommented:
you can try

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

http://www.suite101.com/article.cfm/perl/96608
0
 
joshordanAuthor Commented:
Worked a treat. Many thanks
0
 
apparitionCommented:
You are welcome
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now