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?
perldoc -f alarm
Is that what you mean?
perldoc perlipc
For more about using signals and creating handlers... of course this is when I say that POE allows for this kind of think quite easily, but if you just want something simple then it is overkill.
http://danconia.org
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>