It's not the first time I'm stumbling over the documentation for Carp and it's still confusing me every time...

Point is that carp and croak are meant for reporting module errors but from the perspective of a client who is using a module.

This is decided by checking the package of the subs in the call stack.

BUT if they all belong to the same package they will behave like confess and give the full stacktrace

The following example shows what happens if the call happens from an OTHER package instead of the SAME.

-*- mode: compilation; default-directory: "d:/tmp/job/" -*- Compilation started at Thu Sep 30 17:33:06 C:/Strawberry/perl/bin\perl.exe -w d:/tmp/job/test_carp.pl Perl-Version 5.032001 MSWin32S ====== default $Carp::Verbose =$VAR1 = 0; ====== Setting Verbose to 0 === Testing die Fehlermeldung at d:/tmp/job/test_carp.pl line 27. === Testing croak Fehlermeldung at (eval 6) line 4. === Testing confess Fehlermeldung at d:/tmp/job/test_carp.pl line 29. SAME::throw0("confess") called at d:/tmp/job/test_carp.pl line 34 SAME::throw1("confess") called at d:/tmp/job/test_carp.pl line 38 SAME::throw2("confess") called at (eval 7) line 4 OTHER::client0("confess") called at (eval 7) line 7 OTHER::client1("confess") called at (eval 7) line 9 eval ' package OTHER; use Data::Dumper; sub client0 { SAME::throw2(@_); }; sub client1 { client0(@_); }; client1("confess"); ' called at d:/tmp/job/test_carp.pl line 53 ====== Setting Verbose to 1 === Testing die Fehlermeldung at d:/tmp/job/test_carp.pl line 27. === Testing croak Fehlermeldung at d:/tmp/job/test_carp.pl line 25. SAME::throw0("croak") called at d:/tmp/job/test_carp.pl line 34 SAME::throw1("croak") called at d:/tmp/job/test_carp.pl line 38 SAME::throw2("croak") called at (eval 9) line 4 OTHER::client0("croak") called at (eval 9) line 7 OTHER::client1("croak") called at (eval 9) line 9 eval ' package OTHER; use Data::Dumper; sub client0 { SAME::throw2(@_); }; sub client1 { client0(@_); }; client1("croak"); ' called at d:/tmp/job/test_carp.pl line 53 === Testing confess Fehlermeldung at d:/tmp/job/test_carp.pl line 29. SAME::throw0("confess") called at d:/tmp/job/test_carp.pl line 34 SAME::throw1("confess") called at d:/tmp/job/test_carp.pl line 38 SAME::throw2("confess") called at (eval 10) line 4 OTHER::client0("confess") called at (eval 10) line 7 OTHER::client1("confess") called at (eval 10) line 9 eval ' package OTHER; use Data::Dumper; sub client0 { SAME::throw2(@_); }; sub client1 { client0(@_); }; client1("confess"); ' called at d:/tmp/job/test_carp.pl line 53 Compilation finished at Thu Sep 30 17:33:06

here the code

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery


In reply to Re: $Carp::Verbose ? (SOLVED) by LanX
in thread $Carp::Verbose ? (SOLVED) by LanX

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.