Using `getline' from a Coprocess
--------------------------------
Input into `getline' from a pipe is a one-way operation. The
command that is started with `COMMAND | getline' only sends data _to_
your `awk' program.
On occasion, you might want to send data to another program for
processing and then read the results back. `gawk' allows you start a
"coprocess", with which two-way communications are possible. This is
done with the `|&' operator. Typically, you write data to the
coprocess first, and then read results back, as shown in the following:
print "SOME QUERY" |& "db_server"
"db_server" |& getline
which sends a query to `db_server' and then reads the results.
The values of `NR' and `FNR' are not changed, because the main input
stream is not used. However, the record is split into fields in the
normal manner, thus changing the values of `$0', the other fields, and
of `NF'.
Coprocesses are an advanced feature. They are discussed here only
because this is the minor node on `getline'. Note:Two-Way
Communications with Another Process, where coprocesses are
discussed in more detail.