In Perl 5, I can open a filehandle on string like this:
open my $kfh, "<", \$message->payload;
I have a scenario that uses string as a filehandle and passes it to the open
method:
my $fh = new IO::Zlib;
open my $kfh, "<", \$message->payload;
if($fh->open($kfh, 'rb')){
print <$fh>;
$fh->close;
}
where $message->payload
is read from Kafka, and the content is a byte array. raiph had a similar question, but it didn't answer my question.
So I want to know how to open a filehandle on a string in Perl 6 like Perl 5 does? These documentation pages have no information on this:
EDIT: See this question for how to do what @raiph says about opening a filehandle to a string. Also, read @raiph's comments.
This is how to open a filehandle to a file from a string, not how to open a filehandle to a string without a file being involved. Thanks to @raiph for clarifying the OP's meaning.
The documentation has a section called Input/Output that describes this process.
This is also found in the Perl5 to Perl6 pages as well.
Further references to do this are found in the
IO::Handle
documentation: