--- James Parsons <[EMAIL PROTECTED]> wrote:
> I have this script the calculates the sum  a bunch of  numbers and
> prints the final number to file, but my problem is I would like the
> number to have a floating  $sign but I'm sure how do this
> printf ("%7.2f\n",$total);  
> The number comes out as 120.23   instead of $120.23..

Put it in as a literal, with a \ to quote it.

  printf "\$%7.2f\n", $total;

If you don't want the $ to float out away from the digits, ktry
knocking off the width.

  printf "\$%.2f\n", $total;

but that won't guarantee your width, obviously.
If you need both, try this:

  my $len = 10; # includes newline!
  my $str = (' 'x$len) . sprintf "\$%.2f\n", $total;
  print substr($str,-$len);

That will put leading spaces in front of your output, and leave the
dollar sign adjacent to the numerals. :)


  :o]

__________________________________________________
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to