1Carp::REPL(3)         User Contributed Perl Documentation        Carp::REPL(3)
2
3
4

NAME

6       Carp::REPL - read-eval-print-loop on die and/or warn
7

SYNOPSIS

9       The intended way to use this module is through the command line.
10
11           perl -MCarp::REPL tps-report.pl
12               Can't call method "cover_sheet" without a package or object reference at tps-report.pl line 6019.
13
14           # instead of exiting, you get a REPL!
15
16           $ $form
17           27B/6
18
19           $ $self->get_form
20           27B/6
21
22           $ "ah ha! there's my bug, I thought get_form returned an object"
23           ah ha! there's my bug, I thought get_form returned an object
24

USAGE

26   "-MCarp::REPL"
27   "-MCarp::REPL=warn"
28       Works as command line argument. This automatically installs the die
29       handler for you, so if you receive a fatal error you get a REPL before
30       the universe explodes. Specifying "=warn" also installs a warn handler
31       for finding those mysterious warnings.
32
33   "use Carp::REPL;"
34   "use Carp::REPL 'warn';"
35       Same as above.
36
37   "use Carp::REPL 'nodie';"
38       Loads the module without installing the die handler. Use this if you
39       just want to run "Carp::REPL::repl" on your own terms.
40
41   "use Carp::REPL 'test';"
42   "-MCarp::REPL=test"
43       Load a REPL on test failure! (as long as it uses "ok" in Test::More)
44

FUNCTIONS

46   repl
47       This module's interface consists of exactly one function: repl. This is
48       provided so you may install your own $SIG{__DIE__} handler if you have
49       no alternatives.
50
51       It takes the same arguments as die, and returns no useful value. In
52       fact, don't even depend on it returning at all!
53
54       One useful place for calling this manually is if you just want to check
55       the state of things without having to throw a fake error. You can also
56       change any variables and those changes will be seen by the rest of your
57       program.
58
59           use Carp::REPL 'repl';
60
61           sub involved_calculation {
62               # ...
63               $d = maybe_zero();
64               # ...
65               repl(); # $d = 1
66               $sum += $n / $d;
67               # ...
68           }
69
70       Unfortunately if you instead go with the usual "-MCarp::REPL", then
71       $SIG{__DIE__} will be invoked and there's no general way to recover.
72       But you can still change variables to poke at things.
73

COMMANDS

75       Note that this is not supposed to be a full-fledged debugger. A few
76       commands are provided to aid you in finding out what went awry. See
77       Devel::ebug if you're looking for a serious debugger.
78
79       ·   :u
80
81           Moves one frame up in the stack.
82
83       ·   :d
84
85           Moves one frame down in the stack.
86
87       ·   :top
88
89           Moves to the top frame of the stack.
90
91       ·   :bottom
92
93           Moves to the bottom frame of the stack.
94
95       ·   :t
96
97           Redisplay the stack trace.
98
99       ·   :e
100
101           Display the current lexical environment.
102
103       ·   :l
104
105           List eleven lines of source code of the current frame.
106
107       ·   :q
108
109           Close the REPL. ("^D" also works)
110

VARIABLES

112       ·   $_REPL
113
114           This represents the Devel::REPL object.
115
116       ·   $_a
117
118           This represents the arguments passed to the subroutine at the
119           current frame in the call stack. Modifications are ignored (how
120           would that work anyway?  Re-invoke the sub?)
121

CAVEATS

123       Dynamic scope probably produces unexpected results. I don't see any
124       easy (or even difficult!) solution to this. Therefore it's a caveat and
125       not a bug. :)
126

SEE ALSO

128       Devel::REPL, Devel::ebug, Enbugger, CGI::Inspect
129

AUTHOR

131       Shawn M Moore, "<sartak at gmail.com>"
132

BUGS

134       Please report any bugs or feature requests to "bug-carp-repl at
135       rt.cpan.org", or through the web interface at
136       <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Carp-REPL>.
137

ACKNOWLEDGEMENTS

139       Thanks to Nelson Elhage and Jesse Vincent for the idea.
140
141       Thanks to Matt Trout and Stevan Little for their advice.
142
144       Copyright 2007-2008 Best Practical Solutions.
145
146       This program is free software; you can redistribute it and/or modify it
147       under the same terms as Perl itself.
148
149
150
151perl v5.30.1                      2020-01-29                     Carp::REPL(3)
Impressum