the "if: '$' unknown operator" is, to my knowledge, letting you know thereis a alias thats hasen't been declaired being called. Look around that line for maybe a $alias() that doesn't exist, or maybe confused a var prefix (%) with the alias prefix ($)..
Just a guess.
Also on a side note to those who seem to like to critique, I haven't tries running it so please, no need for the attitudes...