Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

perl have function run every hour

Posted on 2009-04-12
5
Medium Priority
?
210 Views
Last Modified: 2012-05-06
I have a loop in perl which pretty much goes forever.  I have a sleep in this function, which also gets a webpage, so I don't really know how long each loop takes.  I would like my script to call a function every hour (or close to each hour).  How can I do this using a loop?
0
Comment
Question by:jackjohnson44
  • 3
  • 2
5 Comments
 
LVL 85

Expert Comment

by:ozo
ID: 24127318
sleep  60*(60-(localtime)[1]);
0
 

Author Comment

by:jackjohnson44
ID: 24127335
I can't have a sleep because my function is already looping.  I just want it to check inside the loop if it is 1 hr after the program started.  If it is, call a page, reset the timer and check each loop until 1 more hour goes by.
0
 
LVL 85

Accepted Solution

by:
ozo earned 2000 total points
ID: 24127368
if( time-$^T > 3600 ){
  $^T=time;
  call page;
}
0
 

Author Comment

by:jackjohnson44
ID: 24127557
Thanks a lot, it worked well, but what does that ^ mean?

I tried googling it, but it must get stripped out.
0
 
LVL 85

Expert Comment

by:ozo
ID: 24127571
perldoc perlvar
       $BASETIME
       $^T     The time at which the program began running, in seconds since
               the epoch (beginning of 1970).  The values returned by the -M,
               -A, and -C filetests are based on this value.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question