Forum Discussion
hooleylist
Jun 29, 2010Cirrostratus
Unexpected result from foreach loop on 10.2
While testing a simple iRule to print out the contents of an array, I found a weird result when using "foreach {name value} [array get myarray]" on 10.2.0. The unexpected output is bolded below for t...
brad_11480
Sep 16, 2010Nimbostratus
This explains why my code broke and was reporting just as you say.
i changed the references to the second form (requiring another line of code) and it now works.
almost... so i have a side question...
for V10 CMP the $:: syntax is supposed to be eliminated, correct?
i can't figure out what the replacement syntax is to make this work. if i just remove the $ it doesn't provide the value of the array element.... code:
earlier the array "active_clients" was defined:
when RULE_INIT {
array set ::active_clients { }
}
then the routine to display the contents of this array is:
foreach key [array names ::active_clients] {
set value $::active_clients($key)
append rpt "$key$value\n"
}
how do i do this in the "CMP compatible" form?
thanks so much.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects