@@ -698,6 +698,35 @@ C<$sibling> is allowed to be a multi-part path fragment, although
698
698
say '/foo/' .IO.sibling: 'bar'; # OUTPUT: «/bar".IO»
699
699
say '/foo/.'.IO.sibling: 'bar'; # OUTPUT: «/foo/bar".IO»
700
700
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
+
701
730
= head2 routine slurp
702
731
703
732
Defined as:
@@ -993,6 +1022,7 @@ argument.
993
1022
# permissions of file1
994
1023
# to be the same as file2
995
1024
1025
+
996
1026
= end pod
997
1027
998
1028
# vim: expandtab shiftwidth=4 ft=perl6
0 commit comments