There are multiple Tcl interpreters used by BIG-IP at different times, so you can run into cases where an iRule might load via the command line, or iRule editor, or 'b load' but have issues with another. This may change per TMOS version/hotfix.
The best thing to do it try, try, try again with different variations of the syntax. Watch out for curly braces, square brackets, white space, newlines, single quotes, double quotes, and escape sequences. In combination with the desired output and the interpreter sesitivities, you can probably find an acceptable solution. Once you find something that works, check the other interpretter modes to make sure it is a complete solution.
It can be a pain, but isn't too uncommon when multiple interpreter instances are used.