in reply to Format question...

You might want to look into Text::Template.

Regarding using format in a loop, you would just loop through the list of items returned from the database and do a write for each.

--- print map { my ($m)=1<<hex($_)&11?' ':''; $m.=substr('AHJPacehklnorstu',hex($_),1) } split //,'2fde0abe76c36c914586c';