develooper Front page | perl.perl6.users | Postings from August 2020

How to I modify what is a new line in lines?

Thread Next
From:
ToddAndMargo via perl6-users
Date:
August 30, 2020 09:58
Subject:
How to I modify what is a new line in lines?
Message ID:
9a300044-5526-8429-5d1e-c68c3664c20c@zoho.com
Hi All,

https://docs.raku.org/type/IO::Path#method_lines

method lines(IO::Path:D: :$chomp = True, :$enc = 'utf8', :$nl-in = 
["\x0A", "\r\n"], |c --> Seq:D)

How do I change what lines sees as a new line.  Is it
:$nl-in?  A tab in this case.

Some of my missteps:

$ p6 'my $x="a\tb\tc\td\t"; dd $x; for $x.lines(:!chomp, "\t") {dd $_};'
Str $x = "a\tb\tc\td\t"


$ p6 'my $x="a\tb\tc\td\t"; dd $x; for $x.lines(:!chomp, :$nl-in = 
["\x0A", "\r\n"]) {dd $_};'
===SORRY!=== Error while compiling -e
Variable '$nl-in' is not declared
at -e:1
------> tc\td\t"; dd $x; for $x.lines(:!chomp, :⏏$nl-in = ["\x0A", 
"\r\n"]) {dd $_};

$ p6 'my $x="a\tb\tc\td\t"; dd $x; for $x.lines(:!chomp, :nl-in = 
["\x0A", "\r\n"]) {dd $_};'
Str $x = "a\tb\tc\td\t"
Cannot modify an immutable Pair (nl-in => True)
   in block <unit> at -e line 1


Many thanks,
-T

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About