in reply to Printing format

You could use the perl format support for this. This is perl's support for simple report layouts. The docs do a good job of explaining how to use formats, so I won't try to rewrite them here.