Re: Unregognized character \xA0
by jbware (Chaplain) on Feb 02, 2004 at 01:56 UTC
|
The \xA0 is an unprintable character that somehow got into your text. You can either open it up in a hex-capable editor to see where it is or you can just clean all the whitespace out of, and around, the hash. Or, just copy and paste off the PM webpage (not using the "download code" function. That should clear this particular situation up.
- jbWare | [reply] |
|
Actually, "\xA0" is a "non-breaking space" in "Latin1" (ISO 8859-1). I would expect an app like MS-Word to produce a byte like this if it were "preceded" (or "followed", depending on your notion of byte order) by a null byte, indicating UTF-16 encoding. But then I'd expect perl to complain about null bytes (but maybe it wouldn't -- I haven't tried). Or, if Word was using Latin1 as its output encoding (but that seems unexpected).
| [reply] |
|
Okay, thank you. I copied this from a website, there was text formatting when I copied it over into Notepad so maybe that's where the unseen character was hiding. I deleted it and rewrote it myself in Notepad and everything works fine. Very, very weird, but it's all good now. Thanks wise monks!
| [reply] |
Re: Unregognized character \xA0
by BrowserUk (Patriarch) on Feb 02, 2004 at 01:55 UTC
|
Update: Whoops! Guess who just noticed the title of the node. Sorry {blush}!
You appear to have some embedded xAO characters in your code? It would have been helpful if you had told us what the error message was! Is it
Unrecognized character \xA0 at ...?
Are you editing your source files using WORD?
If so, stop. Use notepad, or better still, get yourself a proper code editor, there are plenty available for free on the web.
| [reply] |
Re: Unregognized character \xA0
by Roger (Parson) on Feb 02, 2004 at 01:43 UTC
|
Let me guess, you have recently copied a perl script from DOS/Windows to Unix/Linux, and you didn't convert it to unix format...
Use vi... (^V^M = [Ctrl-V][Ctrl-M])
vi file.pl
:%s/^V^M//g
:x
or use the dos2unix utility.
| [reply] [d/l] [select] |
|
No, I'm writing this myself. My complete script looks like the one at the bottom of this node. But you're right, this IS running on Windows.
#!/usr/bin/perl
use strict;
use warnings;
my %numbers = (
"one" => "1",
"two" => "2",
"three" => "3"
);
print $numbers{"one"};
| [reply] [d/l] |
|
Ok, seems to me that your problem is actually the other-way-round. You created the file in unix format and it does not run under DOS/Windows. Just run the utility unix2dos to convert your script from unix format to dos format.
Update:
I copied this from a website, there was text formatting when I copied it over into Notepad ...
Aha, you didn't mention about that. Problem solved... ;-)
| [reply] [d/l] |
Re: Unregognized character \xA0
by bart (Canon) on Feb 02, 2004 at 08:52 UTC
|
Your source code contains a non-breaking space character, chr(160). Perl can't have that in its source code — only in quoted strings. Please replace it by ordinary whitespace, be it spaces, tabs, newlines... | [reply] |
|
| [reply] |