WC -Sx- Jones wrote:

Why do Perl programmers want to re-invent the wheel?

JupiterHost.Net wrote:

Assume I have a script that will run for 10 seconds.

Is it possible to have a function executed every 2 seconds?

I know it sounds weird but how would one go about something like that?


http://search.cpan.org/~roland/Schedule-Cron-0.05/Cron.pm

no no , not schedule running a script or command every so often. exec a function inside the script every so often

The idea is like this:


actually start the script,
set it up to execute sub { print "$foo\n"; $foo++; } every second during the execution of the script
and if the script was:


#!/usr/bin/perl
use strict;
use warnings;
# now the fake part I'm asking about:
use InsideJob;
my $foo = 0;
my $ij = InsideJob new;
my $job = $ij->job(Name => 'Foo', Exec => sub { print "$foo\n"; $foo++; }, Seconds => 1);
$job->start;
# end fake code
sleep(30);


Would print:

1
2
3
...
30

give or take, make sense?



any such beast?

One halfway semi practical application I could see is, say you have a long running app that prints the date out every so often ( I realize they could use localtime each time but hear me out...


http://search.cpan.org/modlist/Server_Daemon_Utilities

http://search.cpan.org/modlist/Control_Flow_Utilitie


Maybe I could just point out other sections of CPAN? Have you seen the scripts which actually built CPAN?


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to