I think cron would be a better way to handle it, as putting the function in
the bot would mean that a Perl script would have to run all the time. It
seems you would simply be shifting the functionality from cron to your perl
bot. However, if that's what you need, then something like:

while 1
{
sleep(60);
$CurrentTime = GetCurrentTime();
$TargetTime = "16:20";
if $CurrentTime = $TargetTime then

(your code here)

end if;
}

might work, though be aware that you will need to make your script sleep
most of the time for CPU performance reasons. I suggest 60 seconds, so it
should only run at the specified minute.

The function GetCurrentTime() would have to be written of course. I don't
know how to format the perl command localtime to return the current time in
a "00:00" format; I'm still waking up. :)

The localtime command is described here:
http://www.perldoc.com/perl5.8.0/pod/func/localtime.html

There are lots of ways to do this, and surely better ways. Maybe some real
Perl geek could help out...

John Hebert


-----Original Message-----
From: Wade
To: [email protected]
Sent: 8/11/03 6:32 AM
Subject: [brlug-general] perl bot

Maybe someone on the list can help me with this,
I wrote a perl bot that i need to email nightly stats.

Here is the section that does the emailing,

if($email == 1) {
          $sender = Mail::Sender->new({
          smtp => "$mailserver", from => "$fromaddy"});
          $sender->MailFile({to => "$toaddy",
          subject => 'DroneBot update',
          msg => "Up-to-date Drones killed.",
          file => "$logfile"});
        }
        else { _END_ };

What do i need to add for this to run at a certain hour.? 
I know i can make it a separate file and run a cron, but i need it built
in the bot.

Thanks
Wade



_______________________________________________
General mailing list
[email protected]
http://brlug.net/mailman/listinfo/general_brlug.net

Reply via email to