11.7. User-Defined Functionsnawk allows you to define your own functions. This makes it easy to encapsulate sequences of steps that need to be repeated into a single place, and reuse the code from anywhere in your program. Note: for user-defined functions, no space is allowed between the function name and the left parenthesis when the function is called. The following function capitalizes each word in a string. It has one parameter, named input, and five local variables, which are written as extra parameters.
With this input data: A test line with words and numbers like 12 on it. This program produces: A Test Line With Words And Numbers Like 12 On It.
Copyright © 2003 O'Reilly & Associates. All rights reserved. |
|