NAME

GT::IPC::Filter::Line - Implements line based filtering for output streams.


SYNOPSIS

    use GT::IPC::Filter::Line;
    my $filter = new GT::IPC::Filter::Line(
        sub { my $line = shift ... }
    );
    # -or-
    my $filter = new GT::IPC::Filter::Line(
        output => sub { my $out = shift; .. },
        regex  => '\r?\n'
    );
    $filter->put(\$data);
    $filter->flush;


DESCRIPTION

Implements line based filtering to an output code reference. Used mainly in GT::IPC::Run, the GT::IPC::Run manpage for details.


METHODS

There are three methods (as with all filters in this class).

new

Takes either a single argument, which is a code reference to call output with, or a hash of options.

output

This is the code reference you would like called with each line of output. The lines are stripped of there ending before this is called.

regex

Specify the regex to use in order to determine the end of line sequence. This regex is used in a split on the input stream. If you capture in this regex it will break the output.

literal

Specifies a literal new line sequence. The only difference between this option and the regex option is it is quotemeta, See perlfunc/quotemeta.

put

This method takes a stream of data, it converted it into line based data and passes each line to the code reference specified by new(), see new. There is buffering that happens here because we have no way of knowing if the output stream does not end with a new line, also streams almost always get partial lines.

flush

This method should be called last, when the data stream is over. It flushes the remaining buffer out to the code reference.


SEE ALSO

See the GT::IPC::Run manpage.


MAINTAINER

Scott Beck


COPYRIGHT

Copyright (c) 2004 Gossamer Threads Inc. All Rights Reserved. http://www.gossamer-threads.com/


VERSION

Revision: $Id: Line.pm,v 1.7 2004/01/13 01:35:17 jagerman Exp $