I know it's a little late, but if anyone else has this problem I figured I might as well post.

Line 63 is incorrect. This code was ported from C, where == works for everything, but perl likes to do things a little differently.

This:
Code:
elsif ($c == '\n')
should be:
Code:
elsif ($c eq "\n")