Go forward to Getline.
Go backward to Constant Size.
Go up to Reading Files.
Multiple-Line Records
=====================
In some data bases, a single line cannot conveniently hold all the
information in one entry. In such cases, you can use multi-line
records.
The first step in doing this is to choose your data format: when
records are not defined as single lines, how do you want to define them?
What should separate records?
One technique is to use an unusual character or string to separate
records. For example, you could use the formfeed character (written
`\f' in `awk', as in C) to separate them, making each record a page of
the file. To do this, just set the variable `RS' to `"\f"' (a string
containing the formfeed character). Any other character could equally
well be used, as long as it won't be part of the data in a record.
Another technique is to have blank lines separate records. By a
special dispensation, a null string as the value of `RS' indicates that
records are separated by one or more blank lines. If you set `RS' to
the null string, a record always ends at the first blank line
encountered. And the next record doesn't start until the first nonblank
line that follows--no matter how many blank lines appear in a row, they
are considered one record-separator. (End of file is also considered a
record separator.)
The second step is to separate the fields in the record. One way to
do this is to put each field on a separate line: to do this, just set
the variable `FS' to the string `"\n"'. (This simple regular
expression matches a single newline.)
Another way to separate fields is to divide each of the lines into
fields in the normal manner. This happens by default as a result of a
special feature: when `RS' is set to the null string, the newline
character *always* acts as a field separator. This is in addition to
whatever field separations result from `FS'.
The original motivation for this special exception was probably so
that you get useful behavior in the default case (i.e., `FS == " "').
This feature can be a problem if you really don't want the newline
character to separate fields, since there is no way to prevent it.
However, you can work around this by using the `split' function to
break up the record manually (*note Built-in Functions for String
Manipulation: String Functions.).