Sujet : Re: File processing (was Event loop and http::geturl)
De : ralfixx (at) *nospam* gmx.de (Ralf Fassel)
Groupes : comp.lang.tclDate : 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'