in reply to Re^2: Perl6: Capturing newline in a string
in thread Perl6: Capturing newline in a string

Unrelated to your original query, but your module doesn't do quite what it says on the tin. You may wish to emend the documentation.

lines : foo<LF>bar<CR><LF>baz

$ perl -e'use File::Edit::Portable;$r=File::Edit::Portable->new;$h=$r->read("lines");$t=$r->tempfile;print$t $_ while<$h>;$r->write(contents=>$t)'

According to spec, lines should be the same after I ran that as before. In fact it was foo<LF>bar<LF>baz<LF> afterward.

Replies are listed 'Best First'.
Re^4: Perl6: Capturing newline in a string
by stevieb (Canon) on May 31, 2016 at 16:41 UTC

    Nice :)

    Without looking yet, this is because it grabs the first ending it finds (LF, ie. the line ending at the end of the first line in the file), and uses that for all subsequent lines.

    I'll have to put some thought into whether I should review the code to see if there's a sane way to handle this, or update the docs with a warning.

    I can't see too many use cases out there where line endings would be mixed in a single file, but I digress.

    Cheers!