logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Term::Filter::Callback - Simple callback-based wrapper for Term::Filter

Attributes

callbacks
       A hashref of callbacks for Term::Filter. The keys are callback names and the values are coderefs to call
       for those callbacks.

Author

       Jesse Luehrs <doy at tozt dot net>

Description

       This module provides a callback-based API to Term::Filter. The desired callbacks can just be passed into
       the constructor of this class, rather than requiring a new class to be manually defined. This class
       consumes the Term::Filter role, so the rest of the documentation in that module applies here.

Name

       Term::Filter::Callback - Simple callback-based wrapper for Term::Filter

Synopsis

         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');

Version

       version 0.03

See Also