Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages
Carp::REPL(3) User Contributed Perl Documentation Carp::REPL(3)

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

The intended way to use this module is through the command line.

    perl -MCarp::REPL
        Can't call method "cover_sheet" without a package or object reference at line 6019.

    # instead of exiting, you get a REPL!

    $ $form

    $ $self->get_form

    $ "ah ha! there's my bug, I thought get_form returned an object"
    ah ha! there's my bug, I thought get_form returned an object

Works as command line argument. This automatically installs the die handler for you, so if you receive a fatal error you get a REPL before the universe explodes. Specifying "=warn" also installs a warn handler for finding those mysterious warnings.

Same as above.

Loads the module without installing the die handler. Use this if you just want to run "Carp::REPL::repl" on your own terms.

Load a REPL on test failure! (as long as it uses "ok" in Test::More)

This module's interface consists of exactly one function: repl. This is provided so you may install your own $SIG{__DIE__} handler if you have no alternatives.

It takes the same arguments as die, and returns no useful value. In fact, don't even depend on it returning at all!

One useful place for calling this manually is if you just want to check the state of things without having to throw a fake error. You can also change any variables and those changes will be seen by the rest of your program.

    use Carp::REPL 'repl';

    sub involved_calculation {
        # ...
        $d = maybe_zero();
        # ...
        repl(); # $d = 1
        $sum += $n / $d;
        # ...

Unfortunately if you instead go with the usual "-MCarp::REPL", then $SIG{__DIE__} will be invoked and there's no general way to recover. But you can still change variables to poke at things.

Note that this is not supposed to be a full-fledged debugger. A few commands are provided to aid you in finding out what went awry. See Devel::ebug if you're looking for a serious debugger.
  • :u

    Moves one frame up in the stack.

  • :d

    Moves one frame down in the stack.

  • :top

    Moves to the top frame of the stack.

  • :bottom

    Moves to the bottom frame of the stack.

  • :t

    Redisplay the stack trace.

  • :e

    Display the current lexical environment.

  • :l

    List eleven lines of source code of the current frame.

  • :q

    Close the REPL. ("^D" also works)

  • $_REPL

    This represents the Devel::REPL object.

  • $_a

    This represents the arguments passed to the subroutine at the current frame in the call stack. Modifications are ignored (how would that work anyway? Re-invoke the sub?)

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

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

Shawn M Moore, "<sartak at>"

Please report any bugs or feature requests to "bug-carp-repl at", or through the web interface at <>.

Thanks to Nelson Elhage and Jesse Vincent for the idea.

Thanks to Matt Trout and Stevan Little for their advice.

Copyright 2007-2008 Best Practical Solutions.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

2015-06-06 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.