If I'm using the CGI module in Perl, I can do this
$cgi = CGI->new();
$cgi->header(-type=>"text/html");
Or go for the classic
print "Content-Type: text/html\r\n\r\n";
Does it matter which we use? Is there any difference between the two? Both seem to work.
For me I'd go for the first if I was using CGI anyway, but if not then I wouldn't bother loading the module for just one action. But just wondering if there is any thing on the subject?
Psy
Strictly speaking, you have to print \r characters:
print "Content-Type: text/html\r\n\r\n"
is a legal way to express what you want to say.
Generally, I'd stick with what CGI offers. It allows much more concise and readable code, and CGI knows a lot more about such details than you do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With