• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 211
  • Last Modified:

perl have function run every hour

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
jackjohnson44
Asked:
jackjohnson44
  • 3
  • 2
1 Solution
 
ozoCommented:
sleep  60*(60-(localtime)[1]);
0
 
jackjohnson44Author Commented:
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
 
ozoCommented:
if( time-$^T > 3600 ){
  $^T=time;
  call page;
}
0
 
jackjohnson44Author Commented:
Thanks a lot, it worked well, but what does that ^ mean?

I tried googling it, but it must get stripped out.
0
 
ozoCommented:
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now