Devel:...tCache(3pm)
π NAME π
Devel::REPL::Plugin::OutputCache β it remembers your past results for you, and _ is the most recent one. It's a plugin for Devel::REPL, and it lives in the User Contributed Perl Documentation, section 3pm. Bestie, it's giving goldfish with a notebook and I'm obsessed. π§ β¨
β¨ VERSION β¨
This is version 1.003029. Periodt.
πΈ SYNOPSIS πΈ
> 21 / 7
3
> _ * _
9
> sub { die "later" }
sub { die "later" }
> _->()
Runtime error: later
Look at her go. You do a little math, you grab the answer with _, you throw a whole anonymous sub in there, and then you call it with _->(). The vibe check passed. π
π¦ DESCRIPTION π¦
Okay so re-using results is so useful when you're hanging out in a REPL. With OutputCache you get _, and _ holds the past result. The whole point? You can build up your result piece by piece instead of having to type the entire thing in one go, and you don't have to stash stuff in intermediate variables like some kind of Victorian. OutputCache also hands you $_REPL->output_cache, which is an array reference of every result in this session. It's literally the receipts. π§Ύ
Devel::REPL already ships a similar plugin, Devel::REPL::Plugin::History. But there are some key differences, and I need you to pay attention because this is the part where they're not the same girl:
Input vs Output
History remembers input. OutputCache remembers output. Different assignment, same group chat.
Munging vs Pure Perl
History performs regular expressions on your input. OutputCache provides the _ sub as a hook to get the most recent result, plus $_REPL->output_cache for any other results. No regex shenanigans, just Perl doing Perl. πͺ
Principle of Least Surprise
History will replace exclamation points in any part of the input. Which is a problem if you accidentally include one in a string, or in a not expression. Rude, honestly. π OutputCache uses a regular (if oddly named) subroutine, so Perl does the parsing β no surprises.
π CAVEATS π
The_sub is shared across all packages. Which means: 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. And Jifty is the only known user. So if you're running Jifty, bestie, put the plugin down. π
π SEE ALSO π
Devel::REPLDevel::REPL::Plugin::History
π«Ά SUPPORT π«Ά
Bugs may be submitted through the RT bug tracker https://rt.cpan.org/Public/Dist/Display.html?Name=Devel-REPL (or bug-Devel-REPL@rt.cpan.org). They will read it, I promise.
There is also an irc channel available for users of this distribution, at #devel on irc.perl.org (irc://irc.perl.org/#devel-repl). Come hang out, the water's fine. π
π AUTHOR π
Shawn M Moore, <sartak at gmail dot com>. Iconic behavior, truly.
π COPYRIGHT AND LICENSE π
Copyright (C) 2007 by Shawn M Moore
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
And that's the whole page, bestie. It came out of perl v5.34.0, dated 2022-06-03, and it was brought to you by the fine people writing User Contributed Perl Documentation. Now go cache some outputs. πβ¨π¦
π¦ where this page comes from
- debian bookworm: libdevel-repl-perl 1.003029-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libdevel-repl-perl 1.003029-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libdevel-repl-perl 1.003029-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libdevel-repl-perl 1.003029-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libdevel-repl-perl 1.003029-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms