Yikes, I see your confusion -- I left out the extraction of the server details needed to build the array. Sorry about that. I think this is more what you are after:
when HTTP_RESPONSE {
if { [HTTP::header exists "X-WebLogic-Cluster-List"] }{
set server_mappings [split [HTTP::header "X-WebLogic-Cluster-List"] "|" ]
init array if non-existent
array set ::ServerList { }
clear pre-existing array entries
(re-initializing as blank array doesn't seem to do it)
array unset ::ServerList
foreach servermap $server_mappings {
set serverID [getfield $servermap "!" 1]
set serverName [getfield $servermap "!" 2]
set ::ServerList($serverID) [getfield [findclass $serverName $::server_name_to_IP] " " 2]
}
}
}
or to eliminate setting those 2 extra variables, inline substitution gives you:
when HTTP_RESPONSE {
if { [HTTP::header exists "X-WebLogic-Cluster-List"] }{
set server_mappings [split [HTTP::header "X-WebLogic-Cluster-List"] "|" ]
init array if non-existent
array set ::ServerList { }
clear pre-existing array entries
(re-initializing as blank array doesn't seem to do it)
array unset ::ServerList
foreach servermap $server_mappings {
set ::ServerList([getfield $servermap "!" 1]) [getfield [findclass [getfield $servermap "!" 2] $::server_name_to_IP] " " 2]
}
}
}
Clear as mud, now, eh?
(getfield starts indexing @ 1, while lindex starts @ 0.)