method nl-in

Documentation for method nl-in assembled from the following types:

class IO::Handle

From IO::Handle

(IO::Handle) method nl-in

Defined as:

method nl-in(--> Str:Dis rw

One of the attributes that can be set via .new or open. Defaults to ["\x0A", "\r\n"]. Takes either a Str or Array of Str specifying input line ending(s) for this handle. If .chomp attribute is set to True, will strip these endings in routines that chomp, such as get and lines.

with 'test'.IO {
    .spurt: '1foo2bar3foo'# write some data into our test file 
    my $fh will leave {.close} = .open# can also set .nl-in via .open arg 
    $fh.nl-in = [<foo bar>]; # set two possible line endings to use; 
    $fh.lines.say# OUTPUT: ("1", "2", "3").Seq 
}

class IO::CatHandle

From IO::CatHandle

(IO::CatHandle) method nl-in

Defined as:

method nl-in(IO::CatHandle:D:is rw

Sets the invocant's $.nl-in attribute to the assigned value, which can be a Str or a List of Str, where each Str object represents the end-of-line string. All source handles, including the active one will use the provided $.nl-in value. Note that source handle boundary is always counted as a new line break.

(my $f1 = 'foo'.IO).spurt: "A\nB\nC";
(my $f2 = 'bar'.IO).spurt: "DxEx";
with IO::CatHandle.new: $f1$f2 {
    # .nl-in is ["\n", "\r\n"] by default: 
    (.get xx 2).perl.say# OUTPUT: «("A", "B").Seq␤» 
 
    .nl-in = 'x';
    (.get xx 3).perl.say# OUTPUT: «("C", "D", "E").Seq␤» 
    .close
}