Gammon Forum
Entire forum
MUSHclient
Perlscript
ugh help
It is now over 60 days since the last post. This thread is closed.
  Refresh page
Posted by
| MattMc
USA (54 posts) bio
|
Date
| Sun 16 Nov 2003 12:06 AM (UTC) |
Message
| Errors:
Global symbol "$linkfile" requires explicit package name at (eval 2) line 4.
Global symbol "$linkfile" requires explicit package name at (eval 2) line 5.
Global symbol "$nlines" requires explicit package name at (eval 2) line 7.
Global symbol "@file" requires explicit package name at (eval 2) line 7.
Global symbol "$returnstring" requires explicit package name at (eval 2) line 8.
Global symbol "$returnstring" requires explicit package name at (eval 2) line 9.
Global symbol "@file" requires explicit package name at (eval 2) line 9.
Global symbol "$nlines" requires explicit package name at (eval 2) line 9.
Global symbol "$returnstring" requires explicit package name at (eval 2) line 10.
Global symbol "$returnstring" requires explicit package name at (eval 2) line 12.
Not enough arguments for send at (eval 2) line 12, at EOF
(in cleanup) Global symbol "$linkfile" requires explicit package name at (eval 2) line 4.
Global symbol "$linkfile" requires explicit package name at (eval 2) line 5.
Global symbol "$nlines" requires explicit package name at (eval 2) line 7.
Global symbol "@file" requires explicit package name at (eval 2) line 7.
Global symbol "$returnstring" requires explicit package name at (eval 2) line 8.
Global symbol "$returnstring" requires explicit package name at (eval 2) line 9.
Global symbol "@file" requires explicit package name at (eval 2) line 9.
Global symbol "$nlines" requires explicit package name at (eval 2) line 9.
Global symbol "$returnstring" requires explicit package name at (eval 2) line 10.
Global symbol "$returnstring" requires explicit package name at (eval 2) line 12.
Not enough arguments for send
Line in error:
Error number: -2147467259
Event: Execution of line 12 column 0
Called by: Immediate execution
Missing script subroutine procedue:
You have not specified a script file name:
The alias subroutine named "Advertise" could not be found.
The timer (RandomAd) subroutine named "Advertise" could not be found.
XML Error:
Line 48: Could not find all required script routines (problem in this file)
-----------Script----------
<?xml version="1.0" encoding="UTF-8"?>
<muclient>
<plugin name="Random_ads"
author="Matt"
language="perlscript"
id = "982581e59ab42844527eec83"
purpose = "Displays a random ad from time to time"
save_state = "y"
version = "1.1"
requires="3.31"
>
<description trim="y">
<![CDATA[
]]>
</description>
</plugin>
<!-- =============================================
Script: DoRandomAd
Purpose: Chooses an advertisement at random from a text file.
============================================= -->
<timers>
<timer
name="RandomAd"
script="Advertise"
enabled="y"
second="59"
minute="1"
>
</timer>
</timers>
<aliases>
<alias
match="doadnow"
enabled="y"
script="Advertise"
>
</alias>
</aliases>
<script>
<![CDATA[
use strict;
sub Advertise
{
$linkfile = "C:/ads.txt";
open (LINKS, "$linkfile");
srand();
$nlines=@file=<LINKS>;
$returnstring = "emot advertises, '";
$returnstring .= $file[int rand $nlines];
$returnstring .= "'";
world.send $returnstring;
close (LINKS);
}
]]>
</script>
</muclient>
I'm very unfamiliar with scripting perl in mushclient, but I'm thinking I did something extremly wrong. Any help would be greatly appreciated.
The ads.txt file contains 1 line faux-ads (only about 20 of them). 1 per line, hard return at the end. | top |
|
Posted by
| Magnum
Canada (580 posts) bio
|
Date
| Reply #1 on Sun 16 Nov 2003 07:17 AM (UTC) |
Message
| I don't know a thing about Perl, but I know that MUSHclient tries to pass one argument to any subroutine it calls from a timer. (The argument being the Timer Name). Taking a wild guess, it doesn't look like your subroutine accepts arguments.
Hopefully that's one item nailed down... |
Get my plugins here: http://www.magnumsworld.com/muds/
Constantly proving I don't know what I am doing...
Magnum. | top |
|
Posted by
| David Haley
USA (3,881 posts) bio
|
Date
| Reply #2 on Sun 16 Nov 2003 09:28 AM (UTC) Amended on Sun 16 Nov 2003 09:29 AM (UTC) by David Haley
|
Message
|
There's the source of your problem... if you know VB, that's quite similar to Option Explicit.
In other words, all of your variables need to be defined before you use them.
This is generally a good thing to have. You can remove it, but I wouldn't recommend it.
What you should do is declare all variables using "my".
e.g.
my $linkfile = "C:/ads.txt";
You don't need to do this for the file handle; that's the bareword LINKS.
Whenever you see "global symbol (...) requires explicit package name at (...) line ...", that most likely means that you are running in strict mode, and you didn't declare the variable before referring to it. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | top |
|
Posted by
| Nick Gammon
Australia (22,990 posts) bio
Forum Administrator |
Date
| Reply #3 on Wed 19 Nov 2003 05:00 AM (UTC) |
Message
| Perl accepts arguments differently than VBscript, Magnum, so that part is probably OK.
There are example Perl scripts in the MUSHclient distribution.
Choosing one ad out of 20 sounds like the random socials plugin, you could look at how that does it. In its case it stores the messages in a variable saved in the plugin state file. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
Posted by
| MattMc
USA (54 posts) bio
|
Date
| Reply #4 on Wed 19 Nov 2003 10:33 AM (UTC) |
Message
| I figured it out, but couldn't have done it without yalls help :D
Thanks for a wonderful client, Nick.
Joe | 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.
27,299 views.
It is now over 60 days since the last post. This thread is closed.
  Refresh page
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.