Skip to content

Commit 1744820

Browse files
committed
[io grant] Document IO::Path.lines
1 parent 0a9b935 commit 1744820

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

doc/Type/IO/Path.pod6

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,35 @@ C<$sibling> is allowed to be a multi-part path fragment, although
698698
say '/foo/' .IO.sibling: 'bar'; # OUTPUT: «/bar".IO␤»
699699
say '/foo/.'.IO.sibling: 'bar'; # OUTPUT: «/foo/bar".IO␤»
700700
701+
=head2 method lines
702+
703+
Defined as:
704+
705+
method lines(IO::Path:D:
706+
:$chomp = True, :$enc = 'utf8', :$nl-in = ["\x0A", "\r\n"], |c --> Seq:D
707+
)
708+
709+
Opens the invocant and returns its L«lines|/type/IO::Handle#routine_lines».
710+
711+
The behaviour is equivalent to L<opening|/routine/open> the file specified by
712+
the invocant, forwarding the C<:$chomp>, C<:$enc>, and C<:$nl-in> arguments to
713+
L«C<IO::Handle.open>|/type/IO::Handle#routine_open», then calling
714+
L«C<IO::Handle.lines>|/type/IO::Handle#routine_lines» on that handle, forwarding
715+
any of the remaining arguments to that method, and returning the resultant
716+
L<Seq>.
717+
718+
B<NOTE:> the lines are read lazily, so ensure the returned L<Seq> is either
719+
L<fully reified|/language/glossary#index-entry-Reify> or you'll be leaking open
720+
file handles. (TIP: use the
721+
L«C<$limit> argument|/type/IO::Handle#routine_lines»)
722+
723+
=begin code :skip-test
724+
say "The file contains ",
725+
'50GB-file'.IO.lines.grep(*.contains: 'Perl').elems,
726+
" lines that mention Perl";
727+
# OUTPUT: «The file contains 72 lines that mention Perl␤»
728+
=end code
729+
701730
=head2 routine slurp
702731
703732
Defined as:
@@ -993,6 +1022,7 @@ argument.
9931022
# permissions of file1
9941023
# to be the same as file2
9951024
1025+
9961026
=end pod
9971027

9981028
# vim: expandtab shiftwidth=4 ft=perl6

0 commit comments

Comments
 (0)