Devel:...tCache(3pm)

πŸ“¦
version 1.003029 Β· 5 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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::REPL
  • Devel::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 (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