Term::...llback(3pm)

πŸ“¦
version 0.03 Β· 2 versions
  • 0.03 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.03 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Term::Filter::Callback πŸ’–

okay bestie, so this is a page from the User Contributed Perl Documentation section of the manual, and it's about Term::Filter::Callback β€” a little module that's genuinely so iconic. it's the simple callback-based wrapper for Term::Filter, iykyk 🫢


✨ NAME ✨

Term::Filter::Callback β€” a simple callback-based wrapper for Term::Filter. that's the whole vibe. slay.


🌸 VERSION 🌸

version 0.03. yes, it's giving small number, but she works fr fr πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

okay so here's the whole thing in action, look at her go:

use Term::Filter::Callback;

my $term = Term::Filter::Callback->new(
    callbacks => {
        munge_input => sub {
            my $self = shift;
            my ($got) = @_;
            $got =~ s/\ce/E-  Elbereth\n/g;
            $got;
        },
        munge_output => sub {
            my $self = shift;
            my ($got) = @_;
            $got =~ s/(Elbereth)/\e[35m$1\e[m/g;
            $got;
        },
    },
);

$term->run('nethack');

like. that's it. that's the whole setup. no subclassing, no boilerplate, no drama πŸ’– and then you just run nethack and your Elbereths come out purple. main character energy honestly.


πŸ¦‹ DESCRIPTION πŸ¦‹

so this module hands you a callback-based API to Term::Filter. the whole point is: you can just pass the callbacks you want straight into the constructor of this class instead of having to sit there and manually define a whole new class like some kind of Victorian programmer 😭

and the big flex β€” this class consumes the Term::Filter role, so literally all the rest of the documentation over in that module applies here too. periodt. go read it. it's your homework bestie πŸ“šβœ¨


πŸ‘‘ ATTRIBUTES πŸ‘‘

πŸ“ callbacks

a hashref of callbacks for Term::Filter.

  • the keys are the callback names
  • the values are the coderefs to call for those callbacks

that's it. that's the attribute. simple, clean, iconic πŸ’…


πŸ’œ AUTHOR πŸ’œ

Jesse Luehrs <doy at tozt dot net> β€” thank you for your service 🫢✨


this software is copyright (c) 2012 by Jesse Luehrs.

and it's free software bestie β€” you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. no cap, that's genuinely generous of her πŸ’–


⭐ little sign-off moment: this page is from perl v5.34.0 and it got dated 2022-06-17. so yeah, go forth and munge some input, gorgeous πŸ§šπŸ’…πŸŒΈ
πŸ“¦ where this page comes from