What are you talking about? croak and carp don't create a stack trace.

>type script.pl use M1 qw( ); sub test2 { M1::test3(); } sub test1 { test2(); } test1(); >type M1.pm package M1; use M2 qw( ); sub test4 { M2::test5(); } sub test3 { test4(); } 1; >type M2.pm package M2; use Carp qw( croak ); sub test5 { croak("ribbit"); } 1; >perl script.pl ribbit at M1.pm line 3

Although you can force them to produce a stack trace.

>perl -MCarp=verbose script.pl ribbit at M2.pm line 3 M2::test5() called at M1.pm line 3 M1::test4() called at M1.pm line 4 M1::test3() called at script.pl line 2 main::test2() called at script.pl line 3 main::test1() called at script.pl line 4

If there's a reason against using carp and croak, it's that they hide the true source of the error in an attempt to tidily show the actual source of the error. When that's not good, the person debugging the problem can turn on verbose mode and get the information he needs.


In reply to Re: Replacing warn/die with carp/croak? by ikegami
in thread Replacing warn/die with carp/croak? by dragonchild

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.