Devel::REPL::Plugin::OutputCache(3pm)

Devel::REPL::Plugin::OutputCache3pm

Remember past results, _ is most recent

Usage

    > 21 / 7
    3
    > _ * _
    9
    > sub { die "later" }
    sub { die "later" }
    > _->()
    Runtime error: later

Version

version 1.003029

Overview

Re-using results is very useful when working in a REPL. With "OutputCache" you get "_", which holds the past result. The benefit is that you can build up your result instead of having to type it in all at once, or store it in intermediate variables. "OutputCache" also provides "$_REPL->output_cache", an array reference of all results in this session.

Devel::REPL already has a similar plugin, Devel::REPL::Plugin::History. There are some key differences though:

Input vs Output

"History" remembers input. "OutputCache" remembers output.

Munging vs Pure Perl

"History" performs regular expressions on your input. "OutputCache" provides the "_" sub as a hook to get the most recent result, and "$_REPL->output_cache" for any other results.

Principle of Least Surprise

"History" will replace exclamation points in any part of the input. This is problematic if you accidentally include one in a string, or in a "not" expression. "OutputCache" uses a regular (if oddly named) subroutine so Perl does the parsing -- no surprises.

Caveats

The "_" sub is shared across all packages. This means that if a module is using the "_" sub, then there is a conflict and you should not use this plugin. For example, Jifty uses the "_" sub for localization. Jifty is the only known user.

Support

Bugs may be submitted through the RT bug tracker <https://rt.cpan.org/Public/Dist/Display.html?Name=Devel-REPL> (or [email protected] <mailto:[email protected]>).

There is also an irc channel available for users of this distribution, at "#devel" on "irc.perl.org" <irc://irc.perl.org/#devel-repl>.

Releases

9 releases since Debian 5.0 (Lenny); the text changed 5 times.

  1. 5.0
  2. 6.0
  3. 7
  4. 8
  5. 9–11
  6. 12–13

Author

Shawn M Moore, "<sartak at gmail dot com>"

From libdevel-repl-perl 1.003029-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.