title: I can create filehandles to strings in Perl 5, how do I do it in Perl 6?
body: <p>In Perl 5, I can create a filehandle to a string and read or write from the string as if it were a file. This is great for working with tests or templates.</p>
  
  <p>For example:</p>
  
  <pre><code>use v5.10; use strict; use warnings;
  
  my $text = "A\nB\nC\n";
  
  open(my $fh, '&lt;', \$text);
  
  while(my $line = readline($fh)){
      print $line;
  }
  </code></pre>
  
  <p>How can I do that in Perl 6? The following <strong><em>doesn't</em></strong> work for Perl 6 (at least not for my instance of Perl6 running on <a href="http://www.moarvm.com" rel="nofollow noreferrer">MoarVM 2015.01</a> from the <a href="http://rakudo.org/downloads/star/" rel="nofollow noreferrer">January 2015 release of Rakudo Star</a> on 64-bit CentOS 6.5):</p>
  
  <pre><code># Warning: This code does not work
  use v6;
  
  my $text = "A\nB\nC\n";
  
  my $fh = $text;
  
  while (my $line = $fh.get ) {
      $line.say;
  }
  # Warning: Example of nonfunctional code
  </code></pre>
  
  <p>I get the error message:</p>
  
  <pre><code>No such method 'get' for invocant of type 'Str'
     in block &lt;unit&gt; at string_fh.p6:8
  </code></pre>
  
  <p>It's not very surprising that Perl5's <code>open(my $fh, '&lt;', \$text)</code> is not the same as Perl6's <code>my $fh = $text;</code>. So the question is: How does one create a virtual file handle from a string in Perl 6 like <code>open(my $fh, '&lt;', \$str)</code> in Perl 5? Or is that something that has yet to be implemented?</p>
  
  <p>UPDATE (writing to a filehandle in Perl 5)</p>
  
  <p>Likewise, you can write to string filehandles in Perl 5:</p>
  
  <pre><code>use v5.10; use strict; use warnings;
  
   my $text = "";
   open(my $fh, '&gt;', \$text);
  
   print $fh "A";
   print $fh "B";
   print $fh "C";
  
   print "My string is '$text'\n";
  </code></pre>
  
  <p>Outputs:</p>
  
  <pre><code> My string is 'ABC'
  </code></pre>
  
  <p>I haven't seen anything remotely similar in Perl 6, yet.</p>