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.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
|