On Tue, Jun 28, 2005 at 06:57:40PM +0100, Dave Mitchell wrote: > On Tue, Jun 28, 2005 at 09:57:11AM -0700, Michael G Schwern wrote: > > On Tue, Jun 28, 2005 at 12:56:43PM +0100, Dave Mitchell wrote: > > > Ok, I admit I was wr... wroo... wronnn... Otherwisely Correct > > > > > > Change 25006 by [EMAIL PROTECTED] on 2005/06/28 11:28:20 > > > > > > move Carp.pod back into Carp.pm > > > > Except now its at the end of the file instead of inline. > > yes, all of 10 lines away from the functions its documenting :-)
Its the principle of the thing. Also, not initializing $Verbose and $MaxEvalLen seems going a little overboard espcially when it violates the docs. Finally I threw in "our" onto the globals so one can turn on strict during testing. And a version bump. The next target for "use less 'memory'" should probably be Exporter. -- Michael G Schwern [EMAIL PROTECTED] http://www.pobox.com/~schwern Reality is that which, when you stop believing in it, doesn't go away. -- Phillip K. Dick
--- lib/Carp.pm 2005/06/28 18:18:18 1.1 +++ lib/Carp.pm 2005/06/28 18:23:52 @@ -1,43 +1,7 @@ package Carp; -our $VERSION = '1.04'; -# this file is an utra-lightweight stub. The first time a function is -# called, Carp::Heavy is loaded, and the real short/longmessmess_jmp -# subs are installed - -# $MaxEvalLen, $Verbose -# are supposed to default to 0, but undef should be close enough -$CarpLevel = 0; -$MaxArgLen = 64; # How much of each argument to print. 0 = all. -$MaxArgNums = 8; # How many arguments to print. 0 = all. +our $VERSION = '1.05'; -require Exporter; [EMAIL PROTECTED] = ('Exporter'); [EMAIL PROTECTED] = qw(confess croak carp); [EMAIL PROTECTED] = qw(cluck verbose longmess shortmess); [EMAIL PROTECTED] = qw(verbose); # hook to enable verbose mode - -# if the caller specifies verbose usage ("perl -MCarp=verbose script.pl") -# then the following method will be called by the Exporter which knows -# to do this thanks to @EXPORT_FAIL, above. $_[1] will contain the word -# 'verbose'. - -sub export_fail { shift; $Verbose = shift if $_[0] eq 'verbose'; @_ } - -# fixed hooks for stashes to point to -sub longmess { goto &longmess_jmp } -sub shortmess { goto &shortmess_jmp } -# these two are replaced when Carp::Heavy is loaded -sub longmess_jmp {{ local($@, $!); require Carp::Heavy} goto &longmess_jmp} -sub shortmess_jmp {{ local($@, $!); require Carp::Heavy} goto &shortmess_jmp} - -sub croak { die shortmess @_ } -sub confess { die longmess @_ } -sub carp { warn shortmess @_ } -sub cluck { warn longmess @_ } - -1; -__END__ =head1 NAME @@ -187,6 +151,48 @@ Note, this is analogous to using C<use Carp 'verbose'>. Defaults to C<0>. + +=cut + + +# this file is an utra-lightweight stub. The first time a function is +# called, Carp::Heavy is loaded, and the real short/longmessmess_jmp +# subs are installed + +our $MaxEvalLen = 0; +our $Verbose = 0; +our $CarpLevel = 0; +our $MaxArgLen = 64; # How much of each argument to print. 0 = all. +our $MaxArgNums = 8; # How many arguments to print. 0 = all. + +require Exporter; +our @ISA = ('Exporter'); +our @EXPORT = qw(confess croak carp); +our @EXPORT_OK = qw(cluck verbose longmess shortmess); +our @EXPORT_FAIL = qw(verbose); # hook to enable verbose mode + +# if the caller specifies verbose usage ("perl -MCarp=verbose script.pl") +# then the following method will be called by the Exporter which knows +# to do this thanks to @EXPORT_FAIL, above. $_[1] will contain the word +# 'verbose'. + +sub export_fail { shift; $Verbose = shift if $_[0] eq 'verbose'; @_ } + +# fixed hooks for stashes to point to +sub longmess { goto &longmess_jmp } +sub shortmess { goto &shortmess_jmp } +# these two are replaced when Carp::Heavy is loaded +sub longmess_jmp {{ local($@, $!); require Carp::Heavy} goto &longmess_jmp} +sub shortmess_jmp {{ local($@, $!); require Carp::Heavy} goto &shortmess_jmp} + +sub croak { die shortmess @_ } +sub confess { die longmess @_ } +sub carp { warn shortmess @_ } +sub cluck { warn longmess @_ } + +1; + +=cut =head1 BUGS