Search code examples
perltextwrangler

Why is the semicolon unrecognized when running this perl script?


Code from text editor

enter image description here

Terminal Error.

enter image description here

I'm trying to set up Moss(stanford plagarism checker for CS), and when I run the script an error not recognizing semicolon in the script comes up?.

This is being run on Mac OSX using textwrangler as the text editor.

Unrecognized character \xC2; marked by <-- HERE after t_l = "c";<-- HERE near column 14 at ./moss.pl line 173.


Solution

  • It's not complaining about the semi-colon (which is 3B), it's complaining about a byte with value C2 after it. That's not legal ASCII (which is expected if you don't use use utf8;) though it might be the start of a legal UTF-8 sequence (which is expected if you do use use utf8;)

    You don't see it in the terminal or in the editor either because it's also junk to them, or because they expect UTF-8 and it's (the start of) some kind whitespace or unprintable UTF-8 character.

    It's likely a U+00A0 NO-BREAK SPACE, which UTF-8 encodes to C2 A0. This would appear as a normal space in a terminals and editors that expects UTF-8.

    Retype the line to replace the NBSP with a normal space, or add use utf8; to have Perl to treat the source code as UTF-8.