Next: , Previous: , Up: Extension Samples   [Contents][Index]


17.7.8 Two-Way I/O Example

The revtwoway extension adds a simple two-way processor that reverses the characters in each line sent to it for reading back by the awk program. Its main purpose is to show how to write a two-way processor, although it may also be mildly amusing. The following example shows how to use it:

@load "revtwoway"

BEGIN {
    cmd = "/magic/mirror"
    print "don't panic" |& cmd
    cmd |& getline result
    print result
    close(cmd)
}

The output from this program also is: ‘cinap t'nod’.