io - In perl6, how do you read a file in paragraph mode? -
data.txt:
hello world goodbye mars goodbye perl6 hello perl5
myprog.py:
my $fname = 'data.txt'; $infile = open($fname, :r, nl => "\n\n"); $infile.lines(nl => "\n\n") -> $para { $para; '-' x 10; }
actual output:
hello world ---------- goodbye mars ---------- ---------- goodbye perl6 ---------- perl5 ----------
desired output:
hello world goodbye mars ----------- goodbye perl6 perl5 -----------
...
$ perl6 -v perl6 version 2015.03-21-gcfa4974 built on moarvm version 2015.03
this appears bug in rakudo/moarvm, going fact moarvm expects single grapheme separator instead of arbitrary string (cf syncfile.c:38, syncfile.c:119 , syncfile.c:91, shows last character of separator string used instead of whole string).
as quick workaround (but beware reads entire file memory), use
$fname.io.slurp.split("\n\n")
instead of $infile.lines()
.
you should file bug report or ask in #perl6
on freenode if known issue.
Comments
Post a Comment