Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Perlscript ➜ String Issues

String Issues

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


Posted by Sb   (12 posts)  Bio
Date Mon 11 Jul 2005 12:40 AM (UTC)
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...
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #1 on Mon 11 Jul 2005 07:44 AM (UTC)
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.
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #2 on Mon 11 Jul 2005 05:10 PM (UTC)
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
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #3 on Mon 11 Jul 2005 07:53 PM (UTC)
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.
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.


17,264 views.

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

Go to topic:           Search the forum


[Go to top] top

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