in reply to $Carp::Verbose ? (SOLVED)
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: $Carp::Verbose ? (SOLVED)
by LanX (Saint) on Sep 30, 2021 at 17:14 UTC |