I'm coding an iRule on our F5 server but I'm a complete beginner when it comes to TCL.
I have a HTTP::host
variable that contain a hostname in the following format: application-dev.com
All I'm trying to do is split this string where the hyphen occurs and set the first and second sections to separate variables. So I would end up with this:
variable1 = application
variable2 = dev.com
I've gotten this far:
set hostSections [split [HTTP::host] "-"]
But can't find any information on how to assign the sections to seperate variables
You can use
lindex
(list index) for older versions of Tcl:Since lists are 0-indexed,
0
will indicate the first element of the list.In Tcl 8.5 and later, you can use
lassign
which makes things shorter:Both ways stores the values in the variable names
variable1
andvariable2
.