in reply to Re^2: Where does time come from? CORE::GLOBAL:time no honored.
in thread Where does time come from? CORE::GLOBAL:time no honored.

That was your cue to tell us one of them was the time returned by your function, one of them is now, and to tell us which one is which. If that's the case, please do so now. If it isn't the case, please explain what your numbers are.

Do you get the same output from my program as I do? If so, you haven't provided enough info, since overriding time clearly works for you. Please provide more information, preferably less than 25 lines that we can run to repeat the problem.

If you do not get the same output from my program as I do, please provide the output you do get, the output of perl -V.

Replies are listed 'Best First'.
Re^4: Where does time come from? CORE::GLOBAL:time no honored.
by Anonymous Monk on Mar 27, 2009 at 03:27 UTC
    The program I am running is large and I have not been able to reproduce the problem in a small example. You're right, I forgot to mention that the value returned by time() in the program code is not the value returned by my function, but calling time() in the debugger does return the value from my function. Witness:
    500: my $time = time(); DB<4> n Queue::MySQLQ::dequeue(/Users/foo/lib/Queue/MySQLQ.pm:501): 501: my $expire_time = $time + $WORKER_HEARTBEAT_FAILURE; DB<4> x $time 0 1238124047 DB<5> x time() 0 1238124062 DB<6> sleep 2 DB<7> x time() 0 1238124062
    What situation could cause time() in the program code to run different code than time() called in the debugger?

    Thanks for all the help.

      My first thought was that time in my $time = time(); might not be CORE::time(). But it doesn't seem to matter.
      use strict; use warnings; BEGIN { no warnings qw(redefine); *CORE::GLOBAL::time = sub { 4 }; } use subs qw( time ); sub time { 5 } my $time = time(); 1;
      main::(a.pl:12): my $time = time(); DB<1> n main::(a.pl:14): 1; DB<1> x $time 0 5 DB<2> x time() 0 5

      Sorry, no idea.