Re: File processing (was Event loop and http::geturl)

Liste des GroupesRevenir à cl tcl 
Sujet : Re: File processing (was Event loop and http::geturl)
De : ralfixx (at) *nospam* gmx.de (Ralf Fassel)
Groupes : comp.lang.tcl
Date : 26. Jun 2025, 11:14:24
Autres entêtes
Message-ID : <ygaa55uajy7.fsf@akutech.de>
References : 1 2 3 4 5 6 7 8 9 10
User-Agent : Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
* Alan Grunwald <nospam.nurdglaw@gmail.com>
| My pseudo code is generally
>
| while !eof {
|     read a line
|     if line is not empty
|         do stuff
|     endif
| endwhile
>
| I used to be puzzled why I needed the test for non-emptiness. I never
| worked out why, nowadays I simply accept that's the way of things and
| do it.

If the read hits EOF, an empty line is returned which is not actually in
the file.  Depending on your data, this may or may not be a problem
(if you're not interested in empty lines in the data, then no problem).

Usually a better pattern for line-oriented data
on a channel in blocking mode is

  while {[gets $fd line] >= 0} {
    # line has been read, possibly empty
    ...
  }
  close $fd

HTH
R'

Date Sujet#  Auteur
23 Jun 25 * Event loop and http::geturl17Jonathan Kelly
23 Jun 25 +- Re: Event loop and http::geturl1Jonathan Kelly
24 Jun 25 `* Re: Event loop and http::geturl15Rich
24 Jun 25  `* Re: Event loop and http::geturl14Jonathan Kelly
25 Jun 25   `* Re: Event loop and http::geturl13et99
25 Jun 25    `* Re: Event loop and http::geturl12et99
25 Jun 25     `* Re: Event loop and http::geturl11et99
25 Jun 25      `* Re: Event loop and http::geturl10Jonathan Kelly
25 Jun 25       `* Re: Event loop and http::geturl9Rich
26 Jun 25        `* Re: Event loop and http::geturl8et99
26 Jun 25         +* File processing (was Event loop and http::geturl)2Alan Grunwald
26 Jun 25         i`- Re: File processing (was Event loop and http::geturl)1Ralf Fassel
26 Jun 25         `* Re: Event loop and http::geturl5Rich
26 Jun 25          `* Re: Event loop and http::geturl4Jonathan Kelly
26 Jun 25           `* Re: Event loop and http::geturl3et99
27 Jun 25            `* Re: Event loop and http::geturl2Christian Gollwitzer
27 Jun 25             `- Re: Event loop and http::geturl1Ralf Fassel

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal