In article <omi71o$1f0$
1...@news.xmission.com>,
Kenny McCormack <
gaz...@shell.xmission.com> wrote:
>Note: This discussion is all GAWK-specific.
>
>Who hasn't been in this situation? You develop a nice algorithm that
>involves changing RS and everything is fine until you need to read a file
>the normal way (i.e., line-by-line). Now you have to write code to save
>and restore RS - and your formerly nice clean algorithm starts getting
>ugly. And these same comments apply to RT, which is no longer pure and
>clean like before.
>
>Well, where I am going with this is that it would be nice to have RS/RT
>(and some others - see later on) be local to each stream. Note that GAWK
>already has some stream-specific stuff in PROCINFO: e.g.,
>
> PROCINFO["input_name", "READ_TIMEOUT"] and others like that.
>
>There's room in the spec for having a per-stream RS implemented the same
>way.
Well, it's been 5 months since I posted this, and the responses have been
typically useless. All of the responses (workarounds) have both:
1) Utterly missed the point.
and
2) Been so trivially obvious as to have obviously already been in the
knowledge base of the OP (me). Or, to put it more bluntly, "No
sh*t, Sherlock!".
That all said, let me note that the OP *was* a little shy on examples (OP
naively assumed that people would be able to work out the examples on their
own), so let me add one now. When using the GAWK networking functionality
to interact with HTTP sites, it is often convenient to change RS and/or
ORS, due to the rather Unix-unfriendly way that the HTTP protocol was
specified (read: It is defined to use what-has-come-to-be-known-as
DOS/Windows line endings rather than Unix style).
The effect of this is that once you've changed RS and ORS, you find that
standard normal things stop working - and you scratch your head - and
eventually you work it out that (OMG!) the reason things aren't working is
because of the changed RS/ORS. And then you have to retro-fit to make the
normal stuff (that expects normal RS/ORS) work as expected without breaking
the networking stuff (that needs the modified RS/ORS). This is a situation
where it would be really nice to be able to specify that the HTTPService
stream use the modified RS/ORS, but that the rest of the program should
continue to behave as expected.
I ran into this today, when I was working on a simple HTTP GET script,
using the "geturl.awk" script from the distro as the basis. I got it all
working (of course), but it certainly would have been nice to have the
functionality as described in this thread.
--
"Women should not be enlightened or educated in any way. They should be
segregated because they are the cause of unholy erections in holy men.
-- Saint Augustine (354-430) --