I happened to be checking 'perldoc Carp' for Carp::longmess, which I've always used, and noticed the documentation is not there in the latest Perl. In fact the documentation was removed in 5.8.9 in commit d735c2e in a patch from Ben Tilly <ben_tilly@operamail.com> 2006-10-22 07:07:23.
Apparently he didn't like because the stack trace is off by one:
- Removed documentation of shortmess and longmess. Unfortunately longmess doesn't do anything particularly reasonable, and it can't be made to do so because of backwards compatibility with code that depended on the old behaviour.
http://www.nntp.perl.org/group/perl.perl5.porters/2006/10/msg117394.html
Does anybody else find that "doesn't do anything particularly reasonable" little extreme? longmess() gives a perfectly good stacktrace up to your current method. He doesn't go so far as to deprecate it though, he just removed the pod. What are other people using to get a stacktrace as a string, these days then?
$ perl test.pl
stacktrace leading to fourth at test.pl line 10
main::third() called at test.pl line 7
main::second() called at test.pl line 4
main::first() called at test.pl line 16
dying in fourth at test.pl line 14
main::fourth() called at test.pl line 10
main::third() called at test.pl line 7
main::second() called at test.pl line 4
main::first() called at test.pl line 16
$ cat -n test.pl
1 use Carp;
2
3 sub first {
4 second();
5 }
6 sub second {
7 third();
8 }
9 sub third {
10 fourth();
11 }
12 sub fourth {
13 print STDERR Carp::longmess('stacktrace leading to fou
+rth');
14 Carp::confess("dying in fourth");
15 }
16 first();