in reply to Re: A value that stays a value (for some time)
in thread A value that stays a value (for some time)

This code has some interesting ideas for running a server returning such value; but; this would mean it isn't a stateless number calculated for that moment ; if I restart the proces (which happens in my cgi's, I don't use mod_perl (yet)) it will change numbers

It would give me the same results if I would do a time() and change the last 2 digits to a 00 and use that as "current string for this time"; what I need is a sort of "random-but-still-the-same for 10 minutes".

Next to that the "five-before-twelve problem" is still in the air with both methods...

  • Comment on Re^2: A value that stays a value (for some time)

Replies are listed 'Best First'.
Re^3: A value that stays a value (for some time)
by liverpole (Monsignor) on Jun 18, 2006 at 15:15 UTC

    I'm unable to see how you can choose a stateless value which is guaranteed to not change for a finite period of time.

    Since the number is stateless, it must depend on some external reference (eg. a timet).  However, you want the value to change, there's no way to avoid getting the value at some arbitrary number of seconds N prior to the number changing, for some N less than the duration you're interested in (here 600 seconds).  So unless I've misunderstood your requirements, I don't see how you what you're looking for is possible.

    Now, if you're willing to accept numbers which are the same for a 10-minute period, just use:

    my $value = int(time / 600);

    But, of course, you still have the problem of having the value change very soon after you choose it.


    s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/
      That's what I currently got; divided by the seconds but want it to be valid for the time it started without writing something to the server; it would be related only to time and the tables I attach to those times.