perl debug tool: when your program dies/warns, always show carp longmess

okay sthen@
This commit is contained in:
espie 2013-03-08 12:12:03 +00:00
parent 674d4b98f7
commit 6bea49c6a0
5 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,15 @@
# $OpenBSD: Makefile,v 1.1.1.1 2013/03/08 12:12:03 espie Exp $
COMMENT = turn every die/warn into carp verbose messages
DISTNAME = Carp-Always-0.12
CATEGORIES = devel
MODULES = cpan
# perl
PERMIT_PACKAGE_CDROM = Yes
PERMIT_PACKAGE_FTP = Yes
PERMIT_DISTFILES_FTP = Yes
.include <bsd.port.mk>

View File

@ -0,0 +1,2 @@
SHA256 (Carp-Always-0.12.tar.gz) = t+BRstcBMmTUumDK2f953pypkRT2TantEUeFePXWGPo=
SIZE (Carp-Always-0.12.tar.gz) = 5418

View File

@ -0,0 +1,24 @@
$OpenBSD: patch-lib_Carp_Always_pm,v 1.1.1.1 2013/03/08 12:12:03 espie Exp $
--- lib/Carp/Always.pm.orig Mon Feb 18 11:24:02 2013
+++ lib/Carp/Always.pm Mon Feb 18 11:25:13 2013
@@ -9,6 +9,8 @@ our $VERSION = '0.12';
use Carp qw(verbose); # makes carp() cluck and croak() confess
+my %OLD_SIG;
+
sub _warn {
if ($_[-1] =~ /\n$/s) {
my $arg = pop @_;
@@ -25,10 +27,9 @@ sub _die {
$arg =~ s/(.*)( at .*? line .*?\n$)/$1/s;
push @_, $arg;
}
+ $SIG{__DIE__} = $OLD_SIG{__DIE__};
die &Carp::longmess;
}
-
-my %OLD_SIG;
BEGIN {
@OLD_SIG{qw(__DIE__ __WARN__)} = @SIG{qw(__DIE__ __WARN__)};

View File

@ -0,0 +1,5 @@
make every warn() and die() complains loudly in the calling package and
elsewhere. More often used on the command line:
perl -MCarp::Always script.pl

View File

@ -0,0 +1,4 @@
@comment $OpenBSD: PLIST,v 1.1.1.1 2013/03/08 12:12:03 espie Exp $
${P5SITE}/Carp/
${P5SITE}/Carp/Always.pm
@man man/man3p/Carp::Always.3p