Ok, I've had CGI::Carp installed and been using it for quite some time. In fact I'm pretty sure it came with the Distro (5.6.1) but it has suddenly ceased to work in the way I am used to it working. For syntax errors, I am just getting the standard "Internal Server Error" message instead of hte more helpful CGI::Carp messags from calling it with "fatalsToBrowser" exported. This is on solaris2.8 /apache.

To make sure I'm not simply insane, I ran the same script under MacPerl and it output the HTML formatted page I expected from Carp.

When calling an error directly, like die "something here"; carp(fatalsToBrowser) works as I expect it to on the solaris box. Its warnings to browser also seems to work properly. The only thing that does not output to the browser is syntax errors.

I've tried it with just the toBrowser exported, with other .pm's included and without; with CGI::Carp in a BEGIN block and not. None of these things seem to make a difference.

Here's the code I'm using to test CGI::Carp's behavior:

#!/usr/local/bin/perl -w BEGIN { use CGI::Carp qw(fatalsToBrowser warningsToBrowser); } #die "This is a fatal error"; $first = "Hello"; #This should produce a warning print "Content-Type: text/html\n\n"; warningsToBrowser(1); print "<HTML><BODY>"; print "Its a beautiful day in the neighborhood,"; print "a beautiful day in the neighborhood...<BR>"; # Add a syntax error. if($second == "Hello") { print "How are ya\n"; } print "</BODY></HTML>";
If i put in the closing curly (the syntax error) it executes properly (its in the code above) and sends the warnings I'd expect. If I remove the closing curlie I get a generic "Internal Server Error" on solaris, but under Macperl I get the following:
# syntax error, near ") print" File 'Calvin:Cleanup At Startup:2852655'; Line 19 # Unmatched right bracket, at end of line File 'Calvin:Cleanup At Startup:2852655'; Line 19 Content-type: text/html <H1>Software error:</H1> <CODE># Execution of Calvin:Cleanup At Startup:2852655 aborted due to +compilation errors. <\/CODE> <P> Please send mail to this site's webmaster for help. # [Thu May 22 01:36:50 2003] Calvin:Cleanup At Startup:2852655: # Exec +ution of Calvin:Cleanup At Startup:2852655 aborted due to compilation + errors.
Which is what I'd expect from CGI::Carp.

So ... does anyone have ANY idea why CGI::Carp would misbehave this way? Its the most recent version (I tried reinsalling with perl -MCPAN -e 'shell', and eventually forced it to reinstall) and it seems to be functioning partially.

Finally, I also checked the normal error logs to see if CGI::Carps output was appering there; it was not.

Any help or adivce appreciated.

Erik

edit jeffa - escape inner closing code tag


In reply to CGI::Carp Doesnt seem to work properly by theAcolyte

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.