Why not adopt me?
NAME
Carp::Reply - get a repl on exceptions in your program
VERSION
version 0.08
SYNOPSIS
perl -MCarp::Reply script.pl
or
use Carp::Reply ();
sub foo {
# ...
Carp::Reply::repl();
# ...
}
DESCRIPTION
Carp::Reply provides a repl to use within an already running program, which can introspect the current state of the program, including the call stack and current lexical variables. It works just like Reply, with the addition of some commands to move around in the call stack.
The package and lexical environment are set to the package and lexical environment of the current stack frame (and are updated when you use any of the commands which move around the stack frames). The lexical variables are aliased to the variable in the stack frame, so if the repl is invoked manually (not through a __DIE__
handler), you can actually modify the contents of lexical variables to use when the repl closes and the app starts running again.
You can start a repl at any given point in your program by inserting a call to Carp::Reply::repl
in your code. In addition, the default import
method for Carp::Reply
installs a __DIE__
handler which automatically launches a repl when an exception is thrown. You can suppress this behavior by passing an empty import list, either via use Carp::Reply ();
or perl -mCarp::Reply
.
If the repl was invoked manually (via calling repl
), you can resume execution of your code by exiting the repl, typically via Ctrl+D
. If it was invoked via the __DIE__
handler, there is no way to resume execution (this is a limitation of perl itself).
FUNCTIONS
repl
Invokes a repl at the current point of execution.
COMMANDS
- #backtrace
-
(Aliases: #trace, #bt)
Displays a backtrace from the location where the repl was invoked. This is run automatically when the repl is first launched.
- #top
-
(Aliases: #t)
Move to the top of the call stack (the outermost call level).
- #bottom
-
(Aliases: #b)
Move to the bottom of the call stack (where the repl was invoked).
- #up
-
(Aliases: #u)
Move up one level in the call stack.
- #down
-
(Aliases: #d)
Move down one level in the call stack.
- #list
-
(Aliases: #l)
Displays a section of the source code around the current stack frame. The current line is marked with a
*
. - #env
-
Displays the current lexical environment.
BUGS
No known bugs.
Please report any bugs to GitHub Issues at https://github.com/doy/carp-reply/issues.
SEE ALSO
SUPPORT
You can find this documentation for this module with the perldoc command.
perldoc Carp::Reply
You can also look for information at:
MetaCPAN
Github
RT: CPAN's request tracker
CPAN Ratings
AUTHOR
Jesse Luehrs <doy@tozt.net>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2013 by Jesse Luehrs.
This is free software, licensed under:
The MIT (X11) License