On Wednesday 17 November 2004 09:52, Bob Showalter wrote: > Joseph Paish wrote: > > following is a sample of a record generated by a perl script i have > > written ( i have put each field on a separate line in this email to > > prevent word-wrapping) : > > > > > > 12/05/2003 > > sold > > 8000 > > widget1 > > 0.055 > > 29.95 > > 30500 > > 0 > > 410.05 > > -173.655333717579 << change to 2 decimal places displayed > > 2225.37658479827 << change to 2 decimal places displayed > > 0.0729631667146973 << change to 4 decimal places displayed > > -173.655333717579 << change to 2 decimal places displayed > > sample_note_here > > > > > > the first 9 fields and the last field are output just the way i want > > them using a simple "print" statement, but the 4 long ones near the > > end are not. > > > > is there some way of using printf formatting on only certain fields > > to modify the way that they are displayed and leave the others alone, > > since the way they are displayed is ok already? > > Use sprintf() on those elements you want specially formatted. > > So instead of > > print $x, $y, $z; > > You can use > > print $x, $y, sprintf('%.02f', $z) > > This will print $z with two places after the decimal, but leave $x and $y > alone.
it worked!! thanks joe -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>