in reply to Carp::longmess not reporting the current line?

After looking into the source I discovered this

sub longmess { local($!, $^E); # Icky backwards compatibility wrapper. :-( # # The story is that the original implementation hard-coded the # number of call levels to go back, so calls to longmess were off # by one. Other code began calling longmess and expecting this # behaviour, so the replacement has to emulate that behaviour. my $cgc = _cgc(); my $call_pack = $cgc ? $cgc->() : caller(); if ( $Internal{$call_pack} or $CarpInternal{$call_pack} ) { return longmess_heavy(@_); } else { local $CarpLevel = $CarpLevel + 1; return longmess_heavy(@_); } }

"of by one" :(

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

Replies are listed 'Best First'.
Re^2: Carp::longmess not reporting the current line?
by shmem (Chancellor) on Jun 01, 2018 at 21:37 UTC

    Holy cow - backward compatibility! We're trapped in the past, and will die from that - it will pull us into oblivion.

    perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
      Backwards compatibility is fine as long as it's documented and a saner alternative is available.

      Unfortunately does Carp also not support error objects...

      ... but at least that's documented.

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