[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Perlscript
. . -> [Subject]  Syntax error
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Syntax error

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Purbam   (8 posts)  [Biography] bio
Date Tue 27 Jan 2015 06:51 AM (UTC)
Message
After porting all of my settings from Lua to Perl (just simply adding '$world->' to the function names), I got some syntax errors in some of my triggers, like:
syntax error at (eval 16) line 4, near ")H"
(in cleanup) Unrecognized character \xF6 in column 171

Commands sent to script from that trigger are quite simple, just some $world->SetVariable. And they all work in Lua. So, I am pretty sure that the commands themselves don't have syntax issues.

Seems that it caused by UTF things?

And also, how should I debug such issues? I am not sure what are the line 4 and column 171 referring to.

Thanks!
[Go to top] top

Posted by Purbam   (8 posts)  [Biography] bio
Date Reply #1 on Tue 27 Jan 2015 09:32 AM (UTC)

Amended on Wed 28 Jan 2015 01:20 AM (UTC) by Purbam

Message
After some debugging, it becomes clear that the problem is caused by encoding issues.
In my trigger, some Chinese characters are captured and passed to Perlscript by $world->SetVariable(x,"%1"), and that caused syntax errors.

No idea on how to fix this. I tried some functions in utf8 module in Perl, but they don't work.
Any ideas?
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Tue 27 Jan 2015 11:23 PM (UTC)
Message
Quote:

And also, how should I debug such issues? I am not sure what are the line 4 and column 171 referring to.


I am no Perl expert, but I expect that is the line and column in the script.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Purbam   (8 posts)  [Biography] bio
Date Reply #3 on Mon 09 Feb 2015 07:25 AM (UTC)
Message
Nick Gammon said:

Quote:

And also, how should I debug such issues? I am not sure what are the line 4 and column 171 referring to.


I am no Perl expert, but I expect that is the line and column in the script.


Yes, it is the line and column of the script.
It was confusing me because it didn't report the exact column of the problematic characters.
Anyway, the error reporting is not a real issue, but the parameter transferring with non-English parameters is. I still have no idea on what exactly happened there.

After some testing, I guess the problem is not either in Perlscript or Mushclient, but should be in the parameter passing between them.
In the mud I am playing, the output uses Chinese character set, say "gb2312". But from the syntax error messages (something like \x8C), it seems that those characters are encoded as utf8 at somewhere, but perl doesn't regard it as utf8.
I tried to decode/encode the characters to force them to be encoded as "gb2312" before passing them to a mushclient function, something like below:
my $var = encode("gb2312", decode("gb2312", "%1"));
$world->FUNCTION("$var");
Sometime it works, but not always.

Also, there are some other interesting observations.
1. Normally, passing a parameter in Chinese to $world->Note("%1") has no problem, but passing it to $world->SetVariable("var", "%1") have problems.
2. Inserting some empty lines around the problematic lines could solve the problem, but not always.
For example, assuming %1 is a string in English, while %2 is a string in Chinese.
1) $world->SetVariable("var1", "%1");
$world->SetVariable("var2", "%2");
This kind of trigger normally has problem when %2 is Chinese characters.
2) But if I insert some empty lines, like:
$world->SetVariable("var1", "%1");

$world->SetVariable("var2", "%2");

Exact same scripts, but just couple more new lines will make it work!


Any thoughts?
Also, would you please provide some more details on how mushclient running a trigger with Perlscript (I mean the triggers defined in GUI or MCL), especially the parameter passing part? Is there any encoding/decoding steps in mushclient when calling perl interpreter?

Thank you very much!
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Tue 10 Feb 2015 04:14 AM (UTC)
Message
How about trying with Lua? I don't know enough about Perlscript to help.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Purbam   (8 posts)  [Biography] bio
Date Reply #5 on Tue 10 Feb 2015 05:17 AM (UTC)
Message
Nick Gammon said:

How about trying with Lua? I don't know enough about Perlscript to help.


My knowledge on Lua is very limited. I would like to stay with Perl if possible, since I don't have to spend more time to learn a new language.
Actually, as I mentioned above, I don't think the problem is in Perl itself, it should be in the parameter passing between Perl and Mushclient. So, if possible, I would like to know more about how a trigger with Perlscript defined in GUI/MCL is executed, and how the strings passed to $world->functions are processed.
Or, is there any debug method that I can use to debug the problem? like an intermediate perl script file which can let me know what exactly are interpreted?
Thanks!
[Go to top] top

Posted by Meerclar   USA  (733 posts)  [Biography] bio
Date Reply #6 on Tue 10 Feb 2015 05:34 AM (UTC)
Message
Seems like your knowledge of perl is limited too. Switching to lua carries the advantage of having a large base of very knowledgeable people on this forum to ask for help. Staying with perl leaves you comparatively alone in the dark because it seems like about 90% of the script writers here are using lua and Nick's personal skills in lua aren't exactly unimpressive. I'd say you're going to have more issues trying to do what you want in perl than you will learning lua and asking questions here when you get stuck.

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


4,324 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]