Array get and foreach statement HELP!

Hi Guys,

i’m going crazy with a simple array operation in a foreach statement. If i run:

when HTTP_REQUEST {

array unset colorcount

array set colorcount {

red 1

green 5

blue 4

white 9 }

foreach {color count} [array get colorcount] { log local0. “Color: $color Count: $count”}

i expect a reply “Color: red Count:1”

But on my logs i’ve got:

Feb 1 16:02:51 local/tmm info tmm[23012]: Rule IRULE-SMS-Sender-Rate : Color: blue Count: blue

Feb 1 16:02:51 local/tmm info tmm[23012]: Rule IRULE-SMS-Sender-Rate : Color: 4 Count: 4

Feb 1 16:02:51 local/tmm info tmm[23012]: Rule IRULE-SMS-Sender-Rate : Color: white Count: white

Feb 1 16:02:51 local/tmm info tmm[23012]: Rule IRULE-SMS-Sender-Rate : Color: 9 Count: 9

i’ve done this simple test because i’m wrinting an irule and i’ve recognized that the foreach statement on arrays seems not working!

Please, help

Regards

Tony

Hi Tony,

See the post below for details on this bug:

Unexpected result from foreach loop on 10.2

http://devcentral.f5.com/Community/GroupDetails/tabid/1082223/asg/50/afv/topic/aft/1172718/aff/5/showtab/groupforums/Default.aspx

Aaron

Thanks Aaron,

i’ve found the post yesterday night… Is there any workaround as far as you know?

it is a foreach statement issue or an array issue?

i have to implement an irule very similar to this one

i was thinking about “table commands” instead of the use of arrays.

what do you think?

Thanks for your help!

Regards

Antonio