Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Right justifying text in a template fieldby olecs (Scribe) |
on Dec 14, 2005 at 13:51 UTC ( [id://516643]=perlquestion: print w/replies, xml ) | Need Help?? |
olecs has asked for the wisdom of the Perl Monks concerning the following question:
Hello all, say I have the following template and code - (note that the code is just for illustration, it might not run): Now, when printing $res AAAA will be left justified and followed by 8 blanks - is it possible to make it right justified using the template mechanism? I could of course resort to using printf instead, but for my current purpose templates feel so right rgds, Ole C. Update As ikegami suggested I will use sprintf inside the pack statement to format the text the way it needs to be, something like:
takes care of it. The reason for using pack in the first place is that I have to create very long lines with different data and a very rigid structure for where the data should be. pack makes it easy to ensure that everything comes in the right place.
Back to
Seekers of Perl Wisdom
|
|