November 1999
Intermediate to advanced
832 pages
19h 28m
English
The scan command parses a string according to a format specification and assigns values to variables. It returns the number of successful conversions it made. The general form of the command is:
scan string format var ?var? ?var? ...
The format for scan is nearly the same as in the format command. There is no %u scan format. The %c scan format converts one character to its decimal value.
The scan format includes a set notation. Use square brackets to delimit a set of characters. The set matches one or more characters that are copied into the variable. A dash is used to specify a range. The following scans a field of all lowercase letters.
scan abcABC {%[a-z]}result
=> 1
set result
=> abc
If the first character in the set ...
Read now
Unlock full access