Solved

perl have function run every hour

Posted on 2009-04-12
5
205 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 84

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 84

Accepted Solution

by:
ozo earned 500 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 84

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

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
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.…
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…

732 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