Two questions

Posted by Girdy on Mon 27 May 2002 05:16 PM — 2 posts, 12,417 views.

#0
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.
Australia Forum Administrator #1
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");