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.
 Entire forum ➜ MUSHclient ➜ Perlscript ➜ Two questions

Two questions

Posting of new messages is disabled at present.

Refresh page


Posted by Girdy   (9 posts)  Bio
Date Mon 27 May 2002 05:16 PM (UTC)
Message
The scripting has been going fine now that I've got a handle on Perlscript. But I've just got two brief questions to help simplify the code.

1. What is the syntax to run a subroutine in another subroutine? (To make a script modular in a sense and to cut down on size of redundant subrountines.)



2. What is the sleep/wait command for Perlscript? I don't want anything major, just a .5 to 1 second wait for two of my programs.
Top

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #1 on Mon 27 May 2002 09:48 PM (UTC)
Message
To call another sub, do something like this:


sub MySub
  {
#  do something here
  }

#
#  Sub Test calls MySub
#
sub Test
  {
  MySub();
  }


As for sleep/wait commands, I did a very recent post on that subject. Basically you don't want to sleep, you want to use timers. eg.


#
#  Send something in 1 second ...
#
$world->DoAfter (1, "eat food");

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


9,625 views.

Posting of new messages is disabled at present.

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.