Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Formatting a number being displayed

Posted on 2004-10-04
3
175 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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

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…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

828 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