in reply to character recognition

Besides what has already been said, you should notice that you are not testing for a match of $line to the regexp. You assigning to $line the result of the match of $_, if already defined, to the regexp. Maybe a typo, but you should use =~.