in reply to Re^2: Print Array items in Fixed width
in thread Print Array items in Fixed width
The only real downside of pack compared with sprintf, is that pack always left justifies the fields where sprintf can do right justification also.
If you need all the fields right justified, there is a simple trick involving 3 reverses:
@data = qw[ the quick brown fox jumps the lazy dog ];; print pack '(A10)*', @data;; the quick brown fox jumps the lazy +dog print scalar reverse pack '(A10)*', map scalar reverse, reverse @data; +; the quick brown fox jumps the lazy + dog
Doesn't help for mixed justification though.
|
|---|