At last, I've worked out why <pre> formatting in Perl CGI is wrong!
The problem: When I dump a file out in a <pre> block, it's
come out with a space in front of every line but the first.
The realisation: I used a $cgi->comment() block to
throw in some debugging comments in a CGI script, and lo and behold every
line but the first had a space in front of it. For some reason, today it
reminded me of the $cgi->p() formatting, which will put a
space between each argument if it's given a list. I'm guessing this
'join with a space' behaviour is going all the way through the rest of the
CGI module routines.
The solution: Write my own <pre> formatter routine, which just
prints '<pre>', the text, and '</pre>'. Ugh. There's
probably a better way somewhere in CGI, but at least I know what's going
wrong.
posted at: 12:56 | path: /tech/perl/web | permanent link to this entry
All posts licensed under the CC-BY-NC license. Author Paul Wayper.