in reply to ppencode

Feed the to your camel and see what happens.
Can't take log of 0 at - line 2.
You could change log to another function that doesn't choke on $_, or you could remove the xor after it so that it applies to the return value from print.