Re: error: unrecognised character \xC2 at the end of line
by cdarke (Prior) on Jun 16, 2009 at 07:22 UTC
|
I'm guessing you put a new-line after the -w (otherwise it would not report line 2). A common cause of these kinds of errors is where the script is not in a text file format. Did you use a non-text format to save the script file, such as rtf or Word format? It should be a text file with no formatting. | [reply] |
|
|
Thanks for the reply. I typed the program in vi editor and saved it. At the command prompt, typed 'perl filename.pl'. I got the error which I mentioned earlier.
| [reply] |
|
|
Save it as text/ASCII ... hexdump
| [reply] |
Re: error: unrecognised character \xC2 at the end of line
by Anonymous Monk on Jun 16, 2009 at 07:24 UTC
|
| [reply] |
Re: error: unrecognised character \xC2 at the end of line
by Marshall (Canon) on Jun 16, 2009 at 11:03 UTC
|
Let's take this one step at a time.
#!/usr/local/bin/perl on Unix like systems is called the
"shebang" line. This is normally:
#!/usr/bin/perl This tells Unix what program to execute. On Windows this is "explained" in a different way.
The "-w" part tells Perl to 'use warnings;'
The 'print("Hi");' is the input to Perl.
So make a file "hello.pl" with:
#!usr/bin/perl -w
print "hello world\n";
on Unix, you should just at least add "X" execute to permissions for at least u+x, (see chmod command).
Don't mess with fancy command line single line programs until you understand how to do this the "normal way".
| [reply] [d/l] |
|
|
I spent a whole day trying to figure out why I could not load a file with the slurp technique because of this error message:
unrecognised character \xC2 at the end of line
It was not until I found this string of comments that I realized my problem was due to my having cut and pasted code from a web page into linux gedit and the underscore character from the cut code was different from the underscore needed on my linux system.
SO WHEN IN DOUBT try TYPING the copied code into your program.
THANKS SO MUCH FOR THIS WEB SITE.
Off to make a contribution now.
| [reply] [d/l] |
Re: error: unrecognised character \xC2 at the end of line
by irah (Pilgrim) on Jun 16, 2009 at 07:14 UTC
|
| [reply] |
Re: error: unrecognised character \xC2 at the end of line
by Anonymous Monk on Jun 16, 2009 at 07:38 UTC
|
Thanks for the reply. I typed the program in vi editor and saved it. At the command prompt, typed 'perl filename.pl'. I got the error which I mentioned earlier. | [reply] |
Re: error: unrecognised character \xC2 at the end of line
by Anonymous Monk on Jun 16, 2009 at 08:20 UTC
|
now its not displaying "hi" | [reply] |
|
|
The "Hi" might be hiding by prefixing your shell prompt, since you omitted the "\n".
If you don't have hexdump then try od -xc filename.pl
| [reply] [d/l] |
|
|
what is? use hexdump foo.pl and post the output in <code>hexdump output here</code> tags
| [reply] [d/l] |
Re: error: unrecognised character \xC2 at the end of line
by Anonymous Monk on Jun 16, 2009 at 08:24 UTC
|
I typed the program in the terminal. | [reply] |
Re: error: unrecognised character \xC2 at the end of line
by Anonymous Monk on Jun 16, 2009 at 08:36 UTC
|
0000000 2123 752f 7273 622f 6e69 702f 7265 206c
0000010 772d 2020 2020 2020 2020 2020 2020 2020
0000020 2020 2020 2020 2020 2020 2020 2020 2020
*
0000050 7270 6e69 2874 a8c2 6948 a8c2 3b29 2020
0000060 2020 2020 2020 2020 2020 2020 2020 2020
*
0000080 2020 2020 2020 2020 2020 2020 0a20 000008e
| [reply] [d/l] |
|
|
What encoding is your file?
I'm guessing UCS2 Big Endian.
This is what i reverse that as
!#u/rsb/nip/re lw- rpni(t¨ÂiH¨Â;)
Notice Hi (or iH) is surrounded by two characters (¨Â).
I think you need to stick with utf8 or ASCII (ascii quotes are hex 22, chr 34). | [reply] [d/l] |
Re: error: unrecognised character \xC2 at the end of line
by Anonymous Monk on Jun 16, 2009 at 08:51 UTC
|
"Hi" is not geting displayed. Please can you tell me what is wrong with the program. | [reply] |
Re: error: unrecognised character \xC2 at the end of line
by Anonymous Monk on Jun 16, 2009 at 08:56 UTC
|
| [reply] |
|
|
In that case the code which you originally showed is not the same as that you are now running. Please show you currect code. It might also be worth capturing the output using something like script(1).
| [reply] |
Re: error: unrecognised character \xC2 at the end of line
by Anonymous Monk on Jun 16, 2009 at 10:30 UTC
|
#!/usr/local/bin/perl -w
print("Hi\n");
| [reply] [d/l] |
Re: error: unrecognised character \xC2 at the end of line
by Anonymous Monk on Jun 16, 2009 at 10:32 UTC
|
$ perl -e 'print "Hello World\n"'
With the above command, 'unrecognised character \xC2 at -e line1' gets displayed | [reply] [d/l] |
Re: error: unrecognised character \xC2 at the end of line
by Anonymous Monk on Jun 16, 2009 at 10:40 UTC
|
Please post the exact procedure I should use. Is there a site I should have checked? | [reply] |