LanX has asked for the wisdom of the Perl Monks concerning the following question:
I'm getting counter intuitive results
From the docs of to Carp#$Carp::Verbose
This variable makes carp() and croak() generate stack backtraces just like cluck() and confess(). This is how use Carp "verbose" is implemented internally.
Defaults to 0.
my results show no difference...
What am I missing?
-*- mode: compilation; default-directory: "d:/tmp/job/" -*- Compilation started at Thu Sep 30 16:29:14 C:/Strawberry/perl/bin\perl.exe -w d:/tmp/job/test_carp.pl Perl-Version 5.032001 MSWin32S ====== default $Carp::Verbose =0 === Testing die Fehlermeldung at d:/tmp/job/test_carp.pl line 24. === Testing croak Fehlermeldung at d:/tmp/job/test_carp.pl line 22. main::throw0("croak") called at d:/tmp/job/test_carp.pl line 31 main::throw1("croak") called at d:/tmp/job/test_carp.pl line 35 main::throw2("croak") called at d:/tmp/job/test_carp.pl line 48 eval {...} called at d:/tmp/job/test_carp.pl line 48 === Testing confess Fehlermeldung at d:/tmp/job/test_carp.pl line 26. main::throw0("confess") called at d:/tmp/job/test_carp.pl line 31 main::throw1("confess") called at d:/tmp/job/test_carp.pl line 35 main::throw2("confess") called at d:/tmp/job/test_carp.pl line 48 eval {...} called at d:/tmp/job/test_carp.pl line 48 ====== Setting Verbose to 0 === Testing die Fehlermeldung at d:/tmp/job/test_carp.pl line 24. === Testing croak Fehlermeldung at d:/tmp/job/test_carp.pl line 22. main::throw0("croak") called at d:/tmp/job/test_carp.pl line 31 main::throw1("croak") called at d:/tmp/job/test_carp.pl line 35 main::throw2("croak") called at d:/tmp/job/test_carp.pl line 48 eval {...} called at d:/tmp/job/test_carp.pl line 48 === Testing confess Fehlermeldung at d:/tmp/job/test_carp.pl line 26. main::throw0("confess") called at d:/tmp/job/test_carp.pl line 31 main::throw1("confess") called at d:/tmp/job/test_carp.pl line 35 main::throw2("confess") called at d:/tmp/job/test_carp.pl line 48 eval {...} called at d:/tmp/job/test_carp.pl line 48 ====== Setting Verbose to 1 === Testing die Fehlermeldung at d:/tmp/job/test_carp.pl line 24. === Testing croak Fehlermeldung at d:/tmp/job/test_carp.pl line 22. main::throw0("croak") called at d:/tmp/job/test_carp.pl line 31 main::throw1("croak") called at d:/tmp/job/test_carp.pl line 35 main::throw2("croak") called at d:/tmp/job/test_carp.pl line 48 eval {...} called at d:/tmp/job/test_carp.pl line 48 === Testing confess Fehlermeldung at d:/tmp/job/test_carp.pl line 26. main::throw0("confess") called at d:/tmp/job/test_carp.pl line 31 main::throw1("confess") called at d:/tmp/job/test_carp.pl line 35 main::throw2("confess") called at d:/tmp/job/test_carp.pl line 48 eval {...} called at d:/tmp/job/test_carp.pl line 48 Compilation finished at Thu Sep 30 16:29:14
here my code
use strict; use warnings; use Carp; #use Data::Dumper; sub out {warn @_,"\n" } out "Perl-Version $] $^OS"; out '====== default $Carp::Verbose =',$Carp::Verbose; my $err_msg = "Fehlermeldung"; sub throw0 { my ($type) = @_; out "=== Testing $type"; eval { goto $type } or die "Testcase '$type' not implemented"; croak: croak $err_msg; die: die $err_msg; confess: confess $err_msg; } sub throw1 { throw0(@_) } sub throw2 { throw1(@_) } for my $verbose ( undef,0,1 ){ if (defined $verbose) { $Carp::Verbose = $verbose; out "====== Setting Verbose to $verbose"; } # --- types of dieing for my $type (qw/die croak confess/){ eval { throw2($type) } or out $@; } } #done_testing();
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
I think I found the issue
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: $Carp::Verbose ?
by roboticus (Chancellor) on Sep 30, 2021 at 15:24 UTC | |
by LanX (Saint) on Sep 30, 2021 at 15:47 UTC | |
|
Re: $Carp::Verbose ? (SOLVED)
by LanX (Saint) on Sep 30, 2021 at 15:41 UTC | |
by LanX (Saint) on Sep 30, 2021 at 17:14 UTC |