This example shows the usage of Stream::Filter.

Filter streams are used to alter and/or filter strings read from another stream. The strings are passed to a filter sub that will return the altered string, or null if the string should be filtered out.



Creates a counter stream that generates numbers from 0 to 9.


This sub is the source of the counter stream. It generates numbers from 0 to 9 in string form.


This sub is the source of the filter stream.

It doubles the read number and appends it together with " * 2 = " to the string. It also filters the value 4 out, which will be missing in the output.


Jens Rieks <parrot at jensbeimsurfen dot de> is the author and maintainer. Please send patches and suggestions to the Perl 6 Internals mailing list.


Copyright (c) 2004, the Perl Foundation.