Perl Monk, Perl Meditation | |
PerlMonks |
Line up cols using printf %m.nfby pgmer6809 (Sexton) |
on Feb 19, 2021 at 02:21 UTC ( [id://11128548]=perlquestion: print w/replies, xml ) | Need Help?? |
pgmer6809 has asked for the wisdom of the Perl Monks concerning the following question: I am trying to write a report and have the decimal points in the various numbers line up properly. But using say %4.2f or % 4.2f or %04.2f all have the same problem when the value in question is zero. Is there a format spec that will fix this? perl -e'$fmt="\n%3d : %04.2f : %3d";printf $fmt,3,12.34,-1;printf $fmt,2,00.00,1;print "\n";'Result
Back to
Seekers of Perl Wisdom
|
|