to functions, as long as the function
knows what to expect.
5. The switch/case statement is
enabled by default. gawk has had switch/case for a long time, but it had
to be enabled at build time, and the
default was not to do so; now it’s
enabled automatically.
6. gawk now supports defining fields
based on field content, instead of
based on the separators between
fields. A new variable, FPAT, is used.
When you assign a string containing a
regular expression to FPAT, gawk
begins splitting fields such that each
field is the text that matched FPAT.
(Normal field splitting is based on the
text in between fields matching the
regular expression in FS.) This is useful
for many kinds of data where FS-based
matching just doesn’t work.
The new patsplit() built-in function
provides access to this functionality for
strings besides the input record. It is
the analogue of awk’s regular split()
function. Additionally, patsplit() lets
you capture the text of the separators
between fields.
7. Standard awk provides only one-way pipelines, either to or from another
process. gawk provides a notation for
opening a two-way pipeline to a co-process. gawk uses the same notation
with special, internally recognized filenames, to provide TCP/IP communication
98 | SEPTEMBER 2011 WWW.LINUXJOURNAL.COM
over sockets. This feature has been
available for a long time.