I have to admit that I misunderstood the way Carp works, but I really struggle with the documentation here.

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

update

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

update

translated the test to a proper module.pm in a separate file with the same result.


In reply to Carp::longmess not reporting the current line? 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.