Text::WikiText::InputFilter - A stream filter
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;
Text::WikiText::InputFilter provides a simple interface to aid parsing line-based, prefix-structured content.
The following methods are available:
new, line_n, last_prefix, last_match, peek, readline, try, match, commit, flush_empty, push_filter, pop_filter.
Create a new input filter over the given string or IO::Handle.
Return the current line number.
Returns the whitespace before the last match. See try and match.
Returns the last match. See try and match.
Returns the current input line with all prefixes removed, or undef if a filter does not match.
Return the current input line unchanged, or undef on end-of-file or error.
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.
Same as try, but removes the match and prefix from the current input line.
Mark the current input line as processed. Future calls to peek or readline will return the next input line.
Skip all input lines containing only whitespace.
Add another input filter. Future calls to peek will strip last_prefix and regexp from the beginning of all lines.
Remove top-most input filter.
Enno Cramer, Mikhael Goikhman
Text::WikiText
To install Text::WikiText, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Text::WikiText
CPAN shell
perl -MCPAN -e shell install Text::WikiText
For more information on module installation, please visit the detailed CPAN module installation guide.