Text::InHTML is a Perl module that turns a plain text string into HTML that when rendered retains its whitespace without pre tags or pre-like CSS. Also HTML is encoded so no HTML is rendered like it would be with pre tags. Useful for displaying source code or a text file on a web page exactly as-is.
More advanced useage includes syntax highlighting.
my $html = Text::InHTML::encode_plain($plain_text_text);
my $syntax_higlighted_diff = Text::InHTML::encode_diff($plain_text_diff);