Term::Filter(3pm) | User Contributed Perl Documentation | Term::Filter(3pm) |
Term::Filter - Run an interactive terminal session, filtering the input and output
version 0.03
package My::Term::Filter; use Moose; with 'Term::Filter'; sub munge_input { my $self = shift; my ($got) = @_; $got =~ s/\ce/E- Elbereth\n/g; $got; } sub munge_output { my $self = shift; my ($got) = @_; $got =~ s/(Elbereth)/\e[35m$1\e[m/g; $got; } My::Term::Filter->new->run('nethack');
This module is a Moose role which implements running a program in a pty while being able to filter the data that goes into and out of it. This can be used to alter the inputs and outputs of a terminal based program (as in the "SYNOPSIS"), or to intercept the data going in or out to record it or rebroadcast it (App::Ttyrec or App::Termcast, for instance).
This role is intended to be consumed by a class which implements its callbacks as methods; for a simpler callback-based API, you may want to use Term::Filter::Callback instead.
The input filehandle to attach to the pty's input. Defaults to STDIN.
The output filehandle to attach the pty's output to. Defaults to STDOUT.
The IO::Pty::Easy object that the subprocess will be run under. Defaults to a newly created instance.
Returns the filehandles which will be monitored for reading. This list defaults to "input" and "pty".
Add an input handle to monitor for reading. After calling this method, the "read" callback will be called with $fh as an argument whenever data is available to be read from $fh.
Remove $fh from the list of input handles being watched for reading.
Run the command specified by @cmd, as though via "system". The callbacks that have been defined will be called at the appropriate times, to allow for manipulating the data that is sent or received.
The following methods may be defined to interact with the subprocess:
No known bugs.
Please report any bugs through RT: email "bug-term-filter at rt.cpan.org", or browse to <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Term-Filter>.
IO::Pty::Easy
App::Termcast
App::Ttyrec
You can find this documentation for this module with the perldoc command.
perldoc Term::Filter
You can also look for information at:
<http://annocpan.org/dist/Term-Filter>
<http://cpanratings.perl.org/d/Term-Filter>
<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Term-Filter>
<http://search.cpan.org/dist/Term-Filter>
Jesse Luehrs <doy at tozt dot net>
This software is copyright (c) 2012 by Jesse Luehrs.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
2017-01-02 | perl v5.24.1 |