in reply to Re: Cron Question
in thread Cron Question

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

Replies are listed 'Best First'.
Re: Re: Re: Cron Question
by lestrrat (Deacon) on Nov 08, 2001 at 05:08 UTC

    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 :-)