Reply to this subject
Start a new subject
 
Refresh page
| Posted by |
Sb
(12 posts) 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... | top |
|
| Posted by |
Flannel
USA (1,230 posts) 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. | top |
|
| Posted by |
David Haley
USA (3,881 posts) 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 | top |
|
| Posted by |
Flannel
USA (1,230 posts) 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. | 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
Start a new subject
 
Refresh page
top
Comments to:
Gammon Software support
Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )