INFORMATION ^

This example shows the usage of Stream::Combiner.

It uses two Stream::Sub, one sub generates an endless stream of line numbers, the other writes just a few lines.

The Stream::Combiner combines both streams line by line. We specify our own combiner sub that concatenates the strings read from both streams together, seperated by a space.

If you specify no combiner sub, a default one will be used that just concatenates both strings. If the _counter sub would add a space after the number, we could use the default combiner (by not calling the combiner method).

FUNCTIONS ^

_main

Creates the 3 Stream objects and dumps the combined stream.

_counter

The _counter sub is used as a source of the counter stream. It writes a string (an increasing number) to the stream each time someone reads the stream.

_text

The _text sub is used as a source of the text stream. It just writes some text to the stream.

The stream is automatically diconnected when the sub returns, which will also terminate the combined stream.

_combiner

This sub is called to combine the two strings read from both streams. The string returned by this sub is immediately returned by the read method of the Combiner stream.

AUTHOR ^

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 ^

Copyright (C) 2004, The Perl Foundation.


parrot