|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Is there a function in perl to allow me to schedule execution? Something like:
schedule('myfunction', 3); Where 'myfunction' is executed in '3' seconds? |
|
#2
|
|||
|
|||
|
sleep(3) ?
#Well, you could probably do something like this:
sleep(3), myfunction(); OR # if you want a child carry on with processing while # waiting for the scheduled function to occur... if(fork == 0){ sleep(3); myfunction(); exit; } # so you could write your own schedule function like this: $func = "print(\"hello\")"; schedule(3,$func); print "$func has been scheduled\n"; sub schedule($$){ if(fork() == 0){ my $sleep = shift; my $cmd = shift; #scheduled process sleep $sleep; eval($cmd); exit; } } |
|
#3
|
|||
|
|||
|
Thanks a million! That's exactly what I was looking for.
|
|
#4
|
|||
|
|||
|
While what he put up is a great example, you'll want to be carful of serval things. When creating a daemon (which is what the above does), you'll want to make sure you don't keep the daemon mounted on a partition that will need to be unmounted -- things like that. There's a whole list of things you need to watch out for, I'm just warning you.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Schedule type function in perl? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|