Jay, although others have recommended you look at the mod_perl guide and
CGI::Carp, I don't think these are exactly what you're looking for.  The
errors you are getting are generated because of 'use strict;' and occur at
compile time; CGI::Carp is capable of redirecting errors to the browser (if
you type "use CGI::Carp 'fatalsToBrowser'").  Hence your script doesn't get
to run at all, and it doesn't produce anything on standard output.  Your web
server redirects this STDOUT to the web browser and redirects STDERR to its
error log.  Also, you never print a valid content-type header on STDOUT so
your web server can't grok it anyway.  What you need to do is send your
ERRORS to STDOUT instead of STDERR and precede their output with
"Content-Type: text/plain\n\n".  I am not totally sure this is possible
(it's a very odd thing to do) but you might try inserting this at the top of
your script (BEFORE 'use strict;'):

BEGIN { print "Content-Type: text/plain\n\n"; *STDERR = *STDOUT }

This is a BEGIN block which is evaluated at compile time.

I'll give this a try, and you can too.  But I wouldn't be surprised if this
just resulted in weirder behavior.  Chances are what you want to do isn't
really the best thing for your situation, perhaps you could describe your
reason for wanting this behavior.  Good luck!

shimon.

p.s. This wasn't really a mod_perl related question, perhaps this wasn't the
best forum to ask it.

Jay Strauss said:
>
> Hi,
>
> I'm asking this again, due to lack of response (but I can't
> believe no one out
> there knows how to do this).
>
> How do I produce an error page (in HTML), when I call the script
> from a browser,
> that looks just like the error screen I get when I run a script
> at the command
> line?
>
> That is, if I run the following script from the command line:
>
> -------
> #!/usr/bin/perl -w
>
> use strict;
> use diagnostics;
>
> ($first, $second) = @ARGV;
>
> exit;
> -------
>
> I'll get a whole bunch of messages telling me I "use strict" and I have
> variables that I didn't define with "my".
>
> But, if I call it from my browser, I just get back a "Internal
> Server Error"
> page.  Instead I want all the diagnostics messages.
>
> Thanks
> Jay
>
> Jay Strauss
> [EMAIL PROTECTED]
> (h) 773.935.5326
> (c) 312.617.0264

Reply via email to