Data Groups (or classes) can be operated on as if they were a TCL list. You can use the TCL list commands to get the length of the list and extract elements. I'm unsure why you want to use an array for this.
If you want to convert the values in the lines of the list into an array, I guess I could understand that but you can still use the list commands to achieve the same goal.
Another question I have is why you are including the number of items after the address in the class item value? Here's some code that will take a class, pull out line by line, convert each line into a separate list (from the comma separated values) and extract the relevant information.
class port_mappings {
"10.10.10.10,4111,4121",
"10.10.10.20,5111,5121"
}
*** BEGIN iRule ***
when HTTP_REQUEST {
iterate through port_mappings class (as a list)
foreach line $::port_mappings {
Create a list from the current line
set item_list [split $line ","]
Extract item 0 (ip address)
set ip [lindex $item_list 0]
iterate through all the port numbers.
for {set x 1} {$x<[llength $item_list]} {incr x} {
set port [lindex $src_list $x]
}
}
}
*** END iRule ***
Sidenote, if you are trying to use the data group with the matchclass command to find a matching ip address, you could use findclass instead and have it return the trailing list of ports if you format the line like this and call findclass with a separator of a space.
"10.10.10.10 4111,4121"
Not sure if this helps you or not, but I hope it gives you some ideas...
-Joe