RE: fractional cents

"McGlinchy, Alistair" <[email protected]>
Newsgroups gmane.comp.lang.perl.fun
Message-ID <6287C027F546514D8C828F2DBFD0F1D549EC62@MSHVSMNSEXP8002.mnsexchange.adroot.marksandspencer.com>
Bernie,

> there's the fairly awful:
> 
>      sprintf ($amt =~ /\.\d\d\d/? "%7.3f": "%7.2f"), $amt
                                             Woops. ^^^^^^^
I think you meant :
       sprintf ($amt =~ /\.\d\d\d/? "%7.3f": "%7.2f" , $amt)

> There *must* be some really sneaky/clever way to switch the 
> format from two placed to three places just when I need it....

I claim neither sneaky nor clever, but I have got a few of %'s,
sprintf's and $amt's, and that can't be bad can it?

sprintf sprintf("%%%d.%df", 7, 2+$amt=~/\...\d/), $amt

Alistair


-----------------------------------------------------------------------


Registered Office:
Marks & Spencer p.l.c
Michael House, Baker Street,
London, W1U 8EP
Registered No. 214436 in England and Wales.

Telephone (020) 7935 4422 
Facsimile (020) 7487 2670

www.marksandspencer.com

Please note that electronic mail may be monitored.

This e-mail is confidential. If you received it by mistake, please let us know and then delete it from your system; you should not copy, disclose, or distribute its contents to anyone nor act in reliance on this e-mail, as this is prohibited and may be unlawful.

The registered office of Marks and Spencer Financial Services PLC, Marks and Spencer Unit Trust Management Limited, Marks and Spencer Life Assurance Limited and Marks and Spencer Savings and Investments Limited is Kings Meadow, Chester, CH99 9FB. These firms are authorised and regulated by the Financial Services Authority.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.