Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old February 26th, 2001, 02:03 PM
MrPoop MrPoop is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2001
Posts: 1 MrPoop User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Is there a function in perl to allow me to schedule execution? Something like:

schedule('myfunction', 3);

Where 'myfunction' is executed in '3' seconds?

Reply With Quote
  #2  
Old February 27th, 2001, 09:04 AM
rfuller rfuller is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Location: Ireland
Posts: 1 rfuller User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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;
}
}




Reply With Quote
  #3  
Old February 27th, 2001, 10:09 PM
MrPoop MrPoop is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2001
Posts: 1 MrPoop User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks a million! That's exactly what I was looking for.

Reply With Quote
  #4  
Old February 28th, 2001, 12:48 AM
JonLed JonLed is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2000
Location: Indiana
Posts: 614 JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 h 49 m 49 sec
Reputation Power: 9
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Schedule type function in perl?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway