in reply to getting html characters to align
Another way would be to wrap your text in a <pre>..</pre> tag - this will preserve the whitespace and also the column widths, but it does that by using a mono-spaced font (one where each letter is given the same space), but this is usually not that pretty.
I think your best solution would be to use a table, where each letter, and space, is put in a single cell. A bit cumbersome but you will then be able to keep the nice font.
These modules both work with array of array structure:
Text::Table::Tiny
Text::Table::HTML
|
|---|