[ Brent Chapman writes: ]
>
> Right idea, but not an ideal implementation. For starters, I'd change the
> "split" line to
> @uptime = split(/\s+/);
> in order to make it less sensitive to the exact spacing of the numbers.
JFTR, in describing split the Camel says:
"If PATTERN is also omitted, the function splits on whitespace,
/\s+/, after skipping any leading whitespace. [...] As a special
case, specifying a space (" ") will split on whitespace just as
split with no arguments does. Thus, split(" ") can be used to
emulate awk's default behavior, whereas split(/ /) will give you as
many null initial fields as there are leading spaces."
(As well as null fields for multiple spaces.) So split(" ") and
split(/ /) are *not* equivalent and split(" ") and split(/\s+/) are
nearly equivalent except for leading whitespace, although by referencing
the array relative to the tail, the distinction is moot in this case.
It should also be noted in the patch that not every uptime(1)
implementation displays load averages, which is required for the code to
work.
--
Dave Wolfe
Follow-Ups:
References:
|
|