Solved

perl have function run every hour

Posted on 2009-04-12
5
192 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 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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 …
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now