Solved

perl have function run every hour

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Awk Question 2 127
.properties file to call function/method 9 61
Put query string from URL request -  PERL HTTP Daemon 2 77
perl: Cleaning meta tags using RegEX 12 75
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.

805 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