Forum Discussion
2 Replies
Sort By
- hooleylistCirrostratusTCL does support boolean short circuiting. So if the first test is anded with the second and the first one fails, the second test isn't attempted.
- The_BhattmanNimbostratusSorry Hoolio,
For example in Perl a short circuit would like the following
($cat eq "al") && (return "Alcohol");
Could there be something equivilant such as
[HTTP::uri eq "Blah"] && pool pool1
-CB
What are you trying to accomplish though? If it's better error handling, I think using 'catch' command would be more optimal.
I don't think the pool command will return any value if the pool exists so it wouldn't be valid boolean result. If the pool doesn't exist, you'll see a TCL error and the connection will be killed.
You can use syntax like that with iRules, but you'd need to keep in mind what the commands return as standard output.
For example this work to only try to decrypt a cookie if the value of the cookie has a length:
if {[string length [HTTP::cookie value $::my_cookie_name]] and [HTTP::cookie decrypt $::my_cookie_name $::my_cookie_passphrase] eq "my-site_[IP::client_addr]"}{
Aaron
I wasn't clear. Boolean short circuit is basically another conditional expression, much like a switch arguments or IF ELSE arguments. Basically it works where the second argument is only executed or evaluated if the first argument meets a value. On perl this type of condition expression is faster then switch statement of IF ELSE. This is because Perl was written to take advantage of that. I wondered if iRULE could support that.