-
Notifications
You must be signed in to change notification settings - Fork 0
Description
To quote from Rob Pike's paper
First, as discussed earlier, the text passed to the actions would be defined, rather than merely selected, by the patterns
Next, the expressions would define how the input is parsed. Instead of using the restrictive idea of afield separator, the iterations implied by closures in the expression can demarcate fields. [...] We can modify this idea to define the ‘fields’ in awk, so
$1defines the first element of the closure (the first line),$2the second, and so on. More interestingly, the closures could generate indices for arrays, so the fields would be called, say,input[1]and so on, perhaps with the unadorned identifier input holding the original intact string. This has the advantage that nested closures can generate multi-dimensional arrays, which is notationally clean.
Essentially, instead of splitting a file into records and processing them one at a time, treat it as a whole, applying rules to every match of a RE found.