1Devel::REPL::Plugin::OuUtspeurtCCaocnhter(i3b)uted PerlDDeovceulm:e:nRtEaPtLi:o:nPlugin::OutputCache(3)
2
3
4
6 Devel::REPL::Plugin::OutputCache - Remember past results, _ is most
7 recent
8
10 version 1.003029
11
13 > 21 / 7
14 3
15 > _ * _
16 9
17 > sub { die "later" }
18 sub { die "later" }
19 > _->()
20 Runtime error: later
21
23 Re-using results is very useful when working in a REPL. With
24 "OutputCache" you get "_", which holds the past result. The benefit is
25 that you can build up your result instead of having to type it in all
26 at once, or store it in intermediate variables. "OutputCache" also
27 provides "$_REPL->output_cache", an array reference of all results in
28 this session.
29
30 Devel::REPL already has a similar plugin, Devel::REPL::Plugin::History.
31 There are some key differences though:
32
33 Input vs Output
34 "History" remembers input. "OutputCache" remembers output.
35
36 Munging vs Pure Perl
37 "History" performs regular expressions on your input. "OutputCache"
38 provides the "_" sub as a hook to get the most recent result, and
39 "$_REPL->output_cache" for any other results.
40
41 Principle of Least Surprise
42 "History" will replace exclamation points in any part of the input.
43 This is problematic if you accidentally include one in a string, or
44 in a "not" expression. "OutputCache" uses a regular (if oddly
45 named) subroutine so Perl does the parsing -- no surprises.
46
48 The "_" sub is shared across all packages. This means that if a module
49 is using the "_" sub, then there is a conflict and you should not use
50 this plugin. For example, Jifty uses the "_" sub for localization.
51 Jifty is the only known user.
52
54 "Devel::REPL", "Devel::REPL::Plugin::History"
55
57 Bugs may be submitted through the RT bug tracker
58 <https://rt.cpan.org/Public/Dist/Display.html?Name=Devel-REPL> (or
59 bug-Devel-REPL@rt.cpan.org <mailto:bug-Devel-REPL@rt.cpan.org>).
60
61 There is also an irc channel available for users of this distribution,
62 at "#devel" on "irc.perl.org" <irc://irc.perl.org/#devel-repl>.
63
65 Shawn M Moore, "<sartak at gmail dot com>"
66
68 Copyright (C) 2007 by Shawn M Moore
69
70 This library is free software; you can redistribute it and/or modify it
71 under the same terms as Perl itself.
72
73
74
75perl v5.36.0 2023-01-20Devel::REPL::Plugin::OutputCache(3)