updated README.md a bit
This commit is contained in:
parent
689735eed8
commit
db77a97119
@ -141,10 +141,27 @@ The typical execution begins with the BEGIN block, goes through pattern-action b
|
|||||||
- string
|
- string
|
||||||
- byte string
|
- byte string
|
||||||
- array
|
- array
|
||||||
|
- function
|
||||||
|
- regular expression
|
||||||
|
|
||||||
|
To know the current type of a value, call typename().
|
||||||
|
|
||||||
|
function f() { return 10; }
|
||||||
|
BEGIN {
|
||||||
|
a="hello";
|
||||||
|
b=12345;
|
||||||
|
print typename(a), typename(b), typename(c), typename(f), typename(1.23), typename(B"world");
|
||||||
|
}
|
||||||
|
|
||||||
|
A regular expression literal is special in that it never appears as an indendent value and still entails a match operation against $0 without an match operator.
|
||||||
|
|
||||||
|
BEGIN { $0="ab"; print /ab/, typename(/ab/); }
|
||||||
|
|
||||||
|
For this reason, there is no way to get the type name of a regular expressin literal.
|
||||||
|
|
||||||
### Pragmas
|
### Pragmas
|
||||||
|
|
||||||
A program item of the file scope can be placed in any source files.
|
A pragma item of the file scope can be placed in any source files.
|
||||||
A pragma item of the global scope can appear only once thoughout the all source files.
|
A pragma item of the global scope can appear only once thoughout the all source files.
|
||||||
|
|
||||||
| | Scope | Values | Description |
|
| | Scope | Values | Description |
|
||||||
@ -180,6 +197,16 @@ Alternatively, you may form an array before passing it to a function.
|
|||||||
BEGIN { x[3]=99; q(x); for (i in x) print i, x[i]; }'
|
BEGIN { x[3]=99; q(x); for (i in x) print i, x[i]; }'
|
||||||
|
|
||||||
|
|
||||||
|
### Positional variable expression
|
||||||
|
|
||||||
|
There are subtle differences when you put an expression for a position variable. In Hawk, most of the ambiguity issues are resolved if you enclose the expression inside parentheses.
|
||||||
|
|
||||||
|
| | HAWK | AWK |
|
||||||
|
|--------------|---------------|-----------------|
|
||||||
|
| $++$++i | syntax error | OK |
|
||||||
|
| $(++$(++i)) | OK | syntax error |
|
||||||
|
|
||||||
|
|
||||||
## Basic Modules <a name="basic-modules"></a>
|
## Basic Modules <a name="basic-modules"></a>
|
||||||
|
|
||||||
### sys
|
### sys
|
||||||
|
Loading…
Reference in New Issue
Block a user