Perl warnings and IIS6

| | Comments (0)
Just did a quick inexaustive test and it looks like IIS6 throws warnings straight out to the browser. I tested with the aid of Fiddler
(a very handy tool for seeing the headers and raw returns when viewing pages in IE) to see what was being returned. I ran the following test script first:
use strict;

warn "This is dumb!";

print "Content-type: text/html\n\n";
print "This is smart!";
That resulted in the following response from the server:
HTTP/1.1 200 OK
Date: Thu, 19 Oct 2006 21:05:40 GMT
Content-Type: text/html
Proxy-Connection: close
Server: Microsoft-IIS/6.0
This is dumb! at C: \Inetpub\cgi-bin\test.pl line 3.
X-Powered-By: ASP.NET

This is smart!

Notice the warning has been thrown out in the headers? Next I overrode warn to do nothing and ran the modified script:

use strict;

BEGIN {
*CORE::GLOBAL::warn = sub { # do nothing };
}

warn "This is dumb!";

print "Content-type: text/html\n\n";

print "This is smart!";

This return what we expect:


HTTP/1.1 200 OK
Date: Thu, 19 Oct 2006 21:12:41 GMT
Content-Type: text/html
Proxy-Connection: close
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET

This is smart!

Next I need to figure out the best way to handle this curious behaviour. I could opt for one of the CPAN modules that pushes warnings and carps into the Event Log, but I don't like that idea. I like the idea of a plain text error_log just like mamma Apache used to make 'em. Hmm...

Thanks to Nik for the talk about overloading and overriding CORE functions, btw!

Leave a comment

About this Entry

This page contains a single entry by Robbie Bow published on October 19, 2006 9:39 PM.

HTML::Tidy - some observations was the previous entry in this blog.

Year Zero is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 4.21-en