Le mar. 9 oct. 2018 à 10:03, ToddAndMargo via perl6-users <perl6-us...@perl.org <mailto:perl6-us...@perl.org>> a écrit :

    Hi All,

    When reading a text file
    https://docs.perl6.org/routine/lines
    seems pretty straight forward.

    Question:  How do I tell when I when I have
    reached the EOF (End Of File)?

    Many thanks,
    -T


On 10/9/18 4:38 AM, Laurent Rosenfeld via perl6-users wrote:
The eof method of the IO::Handle class returns True if you exhausted the contents of the handle, but you generally don't need to use that, since something like:

for'input.txt'.IO.lines->$line{
# Do something with $line
}

will gracefully handle ends of files for you without you having to do anything special.

Hi Laurent,

Thank you!

So loop until lines return false?

Is it just me, or is this not documented on

     https://docs.perl6.org/routine/lines
?

-T
  • eof ? ToddAndMargo via perl6-users
    • Re: eof ? ToddAndMargo via perl6-users
    • Re: eof ? Laurent Rosenfeld via perl6-users
      • Re: eof ? ToddAndMargo via perl6-users

Reply via email to