Stream into a string or from a string. Use print, say to direct output into a string.
my $t = String::Stream.new(); # for both input and output
print $t: "something";
say $t: "something else";
$*IN = Stream.new("puccini");
my $out = say prompt "composer> "; # $out will contain puccini.