#skeys(), #sortkeys()
DESCRIPTION
returns the number of keys in an associative array;
maps those keys to a string variable when used as
'for <stringvar> in #skeys(<array>)';
the keys are sequenced in alphabetically sorted order
or:
returns the number of keys in an associative array;
maps those keys to string variable s1 when used as
'foreach #skeys(<stringvar>, <array>)';
the keys are sequenced in alphabetically sorted order
SYNOPSIS
#skeys(s)
#sortkeys(s)
or:
#skeys(s1,s2)
#sortkeys(s1,s2)
ARGUMENTS
s - an associative array name
or:
s1 - a string variable name
s2 - an associative array name
EXAMPLES
ACMEProcessListChange
init
status =piktstatus
level =piktlevel
task "Report changes to acme ps process list"
input proc "=psls | =trim(160) | =egrep -i acme |
=egrep -iv "grep|pikt|sshd|sleep|defunct|su -|-bash" |
=cut -c 65-"
rule // add current proc to new proc list
=incr(#procs[$inlin])
end
// report new procs not in old proc list
foreach #skeys($p, #procs)
if ! #defined(%procs[$p])
output log "=acmeprocesslistchange_log" "alive: $p"
fi
endforeach
// report old procs not in new proc list
foreach #skeys($p, %procs)
if ! #defined(#procs[$p])
output log "=acmeprocesslistchange_log" "dead: $p"
fi
endforeach
SEE ALSO
#members()
#keys()
#rkeys(), #reversekeys()
Numerical Functions
String Functions