ea7cd05efcf1141df777d05b1a81fc068899c7c1
[p5sagit/p5-mst-13.2.git] / lib / Carp.pm
1 package Carp;
2 our $VERSION = '1.04';
3 # this file is an utra-lightweight stub. The first time a function is
4 # called, Carp::Heavy is loaded, and the real short/longmessmess_jmp
5 # subs are installed
6
7 # $MaxEvalLen, $Verbose
8 # are supposed to default to 0, but undef should be close enough
9
10 $CarpLevel = 0;
11 $MaxArgLen = 64;    # How much of each argument to print. 0 = all.
12 $MaxArgNums = 8;    # How many arguments to print. 0 = all.
13
14 require Exporter;
15 @ISA = ('Exporter');
16 @EXPORT = qw(confess croak carp);
17 @EXPORT_OK = qw(cluck verbose longmess shortmess);
18 @EXPORT_FAIL = qw(verbose);     # hook to enable verbose mode
19
20 # if the caller specifies verbose usage ("perl -MCarp=verbose script.pl")
21 # then the following method will be called by the Exporter which knows
22 # to do this thanks to @EXPORT_FAIL, above.  $_[1] will contain the word
23 # 'verbose'.
24
25 sub export_fail { shift; $Verbose = shift if $_[0] eq 'verbose'; @_ }
26
27 # fixed hooks for stashes to point to
28 sub longmess  { goto &longmess_jmp }
29 sub shortmess { goto &shortmess_jmp }
30 # these two are replaced when Carp::Heavy is loaded
31 sub longmess_jmp  {{ local($@, $!); require Carp::Heavy} goto &longmess_jmp}
32 sub shortmess_jmp {{ local($@, $!); require Carp::Heavy} goto &shortmess_jmp}
33
34 sub croak   { die  shortmess @_ }
35 sub confess { die  longmess  @_ }
36 sub carp    { warn shortmess @_ }
37 sub cluck   { warn longmess  @_ }
38
39 1;