Results 1 to 3 of 3

Thread: Calculating Prices In CGI/Perl

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2000
    Posts
    225

    Calculating Prices In CGI/Perl

    Hi,

    I'm trying to calculate prices in CGI/Perl, but I'm having a problem with the loss of trailing zeros. ie.:

    $Price1 = "1.20";
    $Price2 = "1.50";
    $TotalCost = $Price1 + $Price2;

    '$TotalCost' would have the value of "2.7"... I want to be able to print it with a trailing zero on the end of it, so when I print it out it'll be "2.70" rather than "2.7", for example. How do I do this? I'm assuming this involves string/character checks and manipulation but I'm not sure how to go about it.

    Cheers,

    Git

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Does Perl have a printf or pad function?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2000
    Posts
    225
    To be honest I'm not really sure, as I'm a bit of a newbie at all the functions/etc.. Does anyone know how to do this?

    Cheers,

    Git

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width