LanX has asked for the wisdom of the Perl Monks concerning the following question:
The synopsis says
# warn user (from perspective of caller) carp "string trimmed to 80 chars";
... while it's later corrected to ...
report the error as being from where your module was called.
(a behavior I actually prefer!)
More importantly it says
longmess( "message from cluck() or confess()" );
... but as you can see from the following example the first (i.e. current) line from cluck is omitted.
What am I missing?
use strict; use warnings; TEST::first(1); # 4 package TEST; use Carp qw/carp cluck longmess shortmess/; sub first { second(2); # 10 } sub second { # local $Carp::Verbose=1; carp "Carp Second"; cluck "Cluck Second"; # 16 print shortmess("Shortmess Second"); print longmess("Longmess Second"); }
Carp Second at d:/Users/lanx/pm/carp.pl line 4. Cluck Second at d:/Users/lanx/pm/carp.pl line 16. TEST::second(2) called at d:/Users/lanx/pm/carp.pl line 10 TEST::first(1) called at d:/Users/lanx/pm/carp.pl line 4 Shortmess Second at d:/Users/lanx/pm/carp.pl line 4. Longmess Second at d:/Users/lanx/pm/carp.pl line 10. TEST::first(1) called at d:/Users/lanx/pm/carp.pl line 4
Ironically after activating the $Carp::Verbose flag, shortmess becomes longer than longmess .
Shortmess Second at d:/Users/lanx/pm/carp.pl line 17. TEST::second(2) called at d:/Users/lanx/pm/carp.pl line 10 TEST::first(1) called at d:/Users/lanx/pm/carp.pl line 4 Longmess Second at d:/Users/lanx/pm/carp.pl line 10. TEST::first(1) called at d:/Users/lanx/pm/carp.pl line 4
wot???
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
translated the test to a proper module.pm in a separate file with the same result.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Carp::longmess not reporting the current line?
by LanX (Saint) on Jun 01, 2018 at 19:18 UTC | |
by shmem (Chancellor) on Jun 01, 2018 at 21:37 UTC | |
by LanX (Saint) on Jun 01, 2018 at 22:13 UTC |