Dan_103700
Mar 11, 2011Nimbostratus
Nested Conditionals and NOT conditionals
Hi there,
I've been meaning to ask for awhile how to do nested conditionals and use a "not" operator in iRules.
I frequently end up writing iRules that look like this:
if { $foo starts_with "bar" } {
Do Nothing
} else {
pool foo_pool
}
Would I get the same thing with just:
if { not $foo starts_with "bar" } {
pool foo_pool
}
Also, is it possible to do nested conditionals... something like:
if { {$foo starts_with "bar" or $bar ends_with "foo"} and {$baz == 5} } {
And ideally, combine these 2 to get something like:
if { { {not $foo starts_with "bar"} or $bar ends_with "foo"} and {$baz == 5} } {
I guess if I take the time to learn the operator precedence and how conditional comparisons evaluate from left to right, I wouldn't need the extra nesting. Still, as a programmer, I've always found value in adding extra parenthesis to make conditional logic easier to read. Hopefully, there's some similar syntax in Irules/TCL to do this because trying to program without the extra braces/parenthesis makes my head hurt.
Thanks!
-Dan