Skip to content


Perl warnings and IIS6

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 OKDate: Thu, 19 Oct 2006 21:05:40 GMTContent-Type: text/htmlProxy-Connection: closeServer: Microsoft-IIS/6.0This 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 OKDate: Thu, 19 Oct 2006 21:12:41 GMTContent-Type: text/htmlProxy-Connection: closeServer: Microsoft-IIS/6.0X-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!

Posted in perl.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.