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

Gammon Software Solutions forum

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

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Perlscript
. . -> [Subject]  String Issues

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

String Issues

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Sb   (12 posts)  [Biography] bio
Date Mon 11 Jul 2005 12:40 AM (UTC)  quote  ]
Message

$name = $world->GetVariable("MyName");
$world->send('gtell {g[{R'.$name.'{g]{R Blind!!!');


That works but...
$name = $world->GetVariable("MyName");
$world->send("gtell {g[{R$name{g]{R Blind!!!");
does not. It barks about {g], but that makes no sense...
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #1 on Mon 11 Jul 2005 07:44 AM (UTC)  quote  ]
Message
It's probably looking for a hash named 'name' (and it's going to return a scalar), and then trying to find the element of 'g]' (since the next { makes it no longer a good name). It's probably giving an error (rather than just creating the hash, with an empty value for g]) because it doesn't like the bracket.

Actually, It is, except obviously the bracket can't be part of a variable name, and it warns us about the g being a future keyword.

Another thing that is also important to keep in mind when dealing with brackets is that they can also be misconstrued as regular expression delimiters. It obviously didn't come into play here though, it just popped into my head when I first glanced over the code.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Reply #2 on Mon 11 Jul 2005 05:10 PM (UTC)  quote  ]
Message
If I remember correctly, you can use single quotes to prevent Perl from doing evaluation like that.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #3 on Mon 11 Jul 2005 07:53 PM (UTC)  quote  ]
Message
What you can do is enclose it in brackets (I know, more brackets, lovely, eh?) like this:
$world->send("gtell {g[{R${name}{g]{R Blind!!!");

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[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.


2,850 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

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

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]