While I think that you have stumbled onto an undesirable behavior in CGI::Carp, the bug causing your script to die in the first place is still.... within your script.

However, that said, here's an interesting observation:

With CGI::Carp.....

use CGI::Carp; eval { die "Ouch!" }; print $@, "\n"; __OUTPUT__ Ouch at C:/Perl/lib/CGI/Carp.pm line 312.

With Carp.pm.....

use Carp; eval { die "Ouch" }; print $@, "\n"; __OUTPUT__ Ouch at C:\Perl\scripts\mytest.pl line 6.

And with CORE::die()....

<p> eval { CORE::die "Ouch" } print $@, "\n"; __OUTPUT__ Ouch at C:\Perl\scripts\mytest.pl line 5.

The documentation for CGI::Carp says that in the realm of CGI scripts, you can simply replace "use Carp;" with "use CGI::Carp;". You've discovered that it's not quite that simple... their behavior with respect to reporting a fatal that occurred inside an eval is not uniform.


Dave


In reply to Re: Re: Re: Re: Re: dying in the wrong place while using CGI::Carp by davido
in thread dying in the wrong place while using CGI::Carp by esharris

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.