NAME

Text::WikiText::InputFilter - A stream filter

SYNOPSIS

use Text::WikiText::InputFilter;

my $filter = Text::WikiText::InputFilter->new(\*STDIN);
$filter->push_filter(qr/> ?/);
while (defined ($_ = $filter->readline)) {
	print "$_";
	$filter->commit;
}
$filter->pop_filter;

DESCRIPTION

Text::WikiText::InputFilter provides a simple interface to aid parsing line-based, prefix-structured content.

METHODS

The following methods are available:

new, line_n, last_prefix, last_match, peek, readline, try, match, commit, flush_empty, push_filter, pop_filter.

new handle
new string

Create a new input filter over the given string or IO::Handle.

line_n

Return the current line number.

last_prefix

Returns the whitespace before the last match. See try and match.

last_match

Returns the last match. See try and match.

peek

Returns the current input line with all prefixes removed, or undef if a filter does not match.

readline

Return the current input line unchanged, or undef on end-of-file or error.

try regexp

Try to match regexp against the beginning of the current, filtered input line (see peek). The matched string and any preceeding whitespace can be accessed with last_match and last_prefix. Returns a true value if regexp matched.

match regexp

Same as try, but removes the match and prefix from the current input line.

commit

Mark the current input line as processed. Future calls to peek or readline will return the next input line.

flush_empty

Skip all input lines containing only whitespace.

push_filter regexp

Add another input filter. Future calls to peek will strip last_prefix and regexp from the beginning of all lines.

pop_filter

Remove top-most input filter.

AUTHORS

Enno Cramer, Mikhael Goikhman

SEE ALSO

Text::WikiText