in reply to Cron Question

If it's in a loop, can't you do this?

my $start = time(); while( time() <= $start + 7200 ) { ....sutff.... }

granted, it consumes some cycles... I'm just weary of using SIGALRM and such. Take it as a TMTOWTDI :-)

Replies are listed 'Best First'.
Re: Re: Cron Question
by blakem (Monsignor) on Nov 08, 2001 at 04:48 UTC
    Sidestepping the wisdom of time based loops.....

    Your $start assignment is unnecessary. The special $^T variable already contains that information. (i.e. perl stores the time() value at startup in $^T) So, you could rewrite the above as:

    while ( time-$^T <= 7200 ) { ....sutff.... }
    Note: this is a mod_perl gotcha since the "startup" time could be a looong time ago. $^T is also the value used when the -M, -A, and -C filetest operators determine the relative age of a file. The age is relative to whatever happens to be in $^T, which has implications for any long running perl program.

    -Blake

      Well, it depends on the semantics of the code :-)

      I *usually* want to have the loop to last for X amount of time, and not the script itself. That's where my

      my $start = time()

      ...comes in. And as you said, $^T is sometimes a problem. I like explicit-ness :-)