A different approach would be to use threads, and when the Connected event is called, start a thread that would check the database every so often, and do something accordingly.
threads::shared can also be used to share variables between two threads (since the two threads can't otherwise communicate very easily)
Code:
use threads;
use threads::shared;
# Maybe share an array of queued messages to send out?
our @outbox : shared;
my $t = threads->create (sub {
# Check the db every 15 seconds.
my $timer = time() + 15;
while (1) {
if (time() > $timer) {
# Check the db
&read_notify;
# And when you get something to send,
# you can push(@outbox,"something")
# and your main loop code could check
# that array, and handle the most recent
# item, which might contain a username to
# send to and a message, e.g.
# push (@outbox, 'myname@nowhere.net::something to say');
# Reset the timer
$timer = time() + 15;
}
}
});
$t->detach; # separate it from the main process
}
Joined: 03 May 2006 Posts: 2292 Location: Colorado
Posted: Thu Jun 22, 2006 1:02 pm Post subject:
Yes that syntax looks okay. Your seriously getting annoying though when you continualy ignore peoples suggestions. Turn on strict and warnings and see what errors you get. I'll bet you get some that when fixed will make this bot work. strict and warnings are GOOD, let them help you.
Just add:
Code:
use strict;
use warnings;
At the top of your code and let us know what perl tells you. _________________ Eric256
Proud previous owner and current admin of Bot-depot.com