in reply to sprintf formatting
Look at: http://perldoc.perl.org/functions/sprintf.html and consult your Perl manual about sprintf. Take a stab at it and let us know how it goes. The spec shows how to create fields of a certain number of characters and how to left or right justify things within those fields.