Thomas_Laubrock
Sep 05, 2005Nimbostratus
foreach iterates an array in reverse order
Hi *,
I just fund a false friend.
A foreachstatement like:
array set ersetzer {
"https://portal.domain:80" "https://portal.domain.net"
"http://portal" "https://portal"
}
foreach {myfind myreplace} [array get ersetzer] {
set offset 0
set diff [expr [string length $myreplace] - [string length $myfind]]
Get indices of all instances of find string in the payload
set indices [regexp -all -inline -indices $myfind [HTTP::payload]]
log "Search for: $myfind, replace with $myreplace, found at indices"
[here same code that replaces the strings in the http payload]
}
runs trough the array in reverse order, so this code will first search for "http://portal" and then for "https://portal.domain.net:80"
Because I need the replacements in the right order it is very important, that you know the untypical behaviour for the foreach statement.
Hopefully the netx release will behave in the same way, otherwies ... goob luck and happy iRule debugging :-)
Bye
Thomas