> On 30 Dec 2015, at 17:48, Sam S. (via RT) <[email protected]> 
> wrote:
> 
> # New Ticket Created by  Sam S. 
> # Please include the string:  [perl #127092]
> # in the subject line of all future correspondence about this issue. 
> # <URL: https://rt.perl.org/Ticket/Display.html?id=127092 >
> 
> 
> When called on a string, the .lines method ignores/chomps only *one* trailing 
> newline, and treats all other newlines as line separators:
> 
>    dd "\n\n\n".lines;    # ("", "", "").Seq
> 
> However, when called on an IO::Path or IO::Handle, it ignores/chomps up to 
> *two* trailing newlines:
> 
>    spurt 'a', "\n\n\n";
>    dd 'a'.IO.lines;      # ("", "").Seq
>    dd open('a').lines;   # ("", "").Seq
> 
> Expected behavior: All three examples should print ("", "", "").Seq.

This is really RT #126598 .

The problem is really that with auto-chomping (which is the default), the EOF 
flag is set when the last line of the file has been read.  If that line is 
empty, however, IO::Handle.get cannot see the difference between a “real” end 
of file and an empty line (because the eol delimiter has already been removed). 
 It was felt that it would be better to lose an empty line at the end, then 
adding one that isn’t there.

This will require a fix in MoarVM.



Liz

Reply via email to