Skip to content

Instantly share code, notes, and snippets.

@donaldh

donaldh/read.pl Secret

Created September 6, 2013 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donaldh/4ada7d00c4d64a4efc15 to your computer and use it in GitHub Desktop.
Save donaldh/4ada7d00c4d64a4efc15 to your computer and use it in GitHub Desktop.
my Mu $PIO;
sub read(Cool $bufsize as Int) {
my $res = buf8.new();
repeat {
my $buf := buf8.new();
nqp::readfh($PIO, $buf, nqp::unbox_i($bufsize - $res.elems));
$res ~= $buf;
} while $res.elems < $bufsize && $buf.elems;
$res;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment