in reply to Help with formatting a text file

Either define the format for $key to be large enough to accomodate the longest possible value, or break up the value of $key into (say) 20 character chunks, and print out one such chunk perline (with a new one-line format just for that purpose).

Yeah, sounds clumsy to me, too. I'd go with one of the earlier suggestions.

By the way, if you do continue with formats (I use them), I'd suggest placing them towards the top of your source, or at the very end. Don't put them in the middle, as per your example. It breaks up the flow when reading the source code.