On 19 Apr 2004 at 20:18, McGlinchy, Alistair wrote: > > 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
Indeed, I like it..:o) But on appeal from one of the guys at work who'll have to deal with the code, I'll confess that I took the coward's way out: $money = sprintf "%7.3f", $amt; $money =~ s/0$// ; Not particularly a 'fun' approach, but at least we'll remember what it was doing when we look at the code again in six months..:o) /Bernie\ -- Bernie Cosell Fantasy Farm Fibers mailto:[EMAIL PROTECTED] Pearisburg, VA --> Too many people, too few sheep <--