Any thoughts on how to accomplish that?
Here’s one: Change use Carp; to use MyCarp; and put the module “MyCarp.pm” somewhere in your Perl’s path:
#! perl package MyCarp; use strict; use warnings; use Exporter 'import'; our @EXPORT = 'croak'; sub croak { use Carp 'shortmess'; $Carp::Verbose = 1; my @lines = split /\n/, shortmess @_; s/^\s+// for @lines; die $lines[1] . "\n\t" . $lines[2] . "\n"; } 1;
Example output:
17:22 >perl 1229_SoPW.pl b dying at 1229_SoPW.pl line 23, <> line 1. a MyCarp::croak("croaking") called at 1229_SoPW.pl line 22 MyModule::a("MyModule") called at 1229_SoPW.pl line 30 b dying at 1229_SoPW.pl line 23, <> line 3. Terminating on signal SIGINT(2) 17:22 >
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re^2: Getting croak to show both caller and callee?
by Athanasius
in thread Getting croak to show both caller and callee?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |