The BIG-IP GUI is pretty slick and there have been massive improvements in function and efficiency since my first exposure in version 4.2. As good as it is, however, some tasks are just better suite...
add logging of both what you are passing as an argument, and the list ($rules) before the condition. The stdout should be logged to /var/tmp/scriptd.out.