Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Formatted printing
- Perl Learner
June 14, 2005, 3:12 pm
rate this thread
I am having trouble printing a table of values.
The problem is that the table may contain anything from 2 character
to signed numbers with 6 digits after the decimal.
i am unable to align them properly.
i tried using the following
printf "%3.9s", $variable
printf "%3.9f", $variable
the later serves the purpose for floating point numbers. the former
does somewhat what i want it to do .. it includes spaces before to fill
i didnt know what i was doing so i kept guessing the syntax and came up
with the above.
what i would like it to do is
if this is the max length (shown in X) ..
see how the above is neatly aligned? .. it would be great if there is a
way i could align it like that.
in the example above, i showed "OB" centered and the numbers aligned to
the right.. but i dont mind if all are centered or all are aligned to
the right as long as they're all under those "XXXXXXXXX"s
is there a way to do that with these %s and printfs ?