in reply to Localtime Updating

You didn't show us where $localtime is set, so it could very well be stale. If the transactions really do take less than a second (which is quite possible, not knowing any details) then you might want to look into Time::HiRes
use Time::HiRes qw( time ); sub LOGGIN { my $time = time; my $mili = sprintf("%03d", ($time - int($time)) * 100); my $localtime = localtime($time); open(local *LOG, '>>', $log) or croak "Unable to append to $log: $!"; print LOG "[$localtime.$mili] $log : @data \n"; close LOG or die "Cannot close log file:: $log : $!\n"; }

Replies are listed 'Best First'.
Re^2: Localtime Updating
by Anonymous Monk on Feb 24, 2006 at 15:45 UTC
    I don't know if you all noticed, but this is where in the module localtime gets set.
    It is part of the code in the module like:
    our $localtime = localtime;

      Anonymonk, now explain why you think the value of that scalar should change over time. Do you assign the value of localtime() many times? Do you think that by calling your subroutine, it somehow magically knows to update the value stored in $localtime? I don't understand your difficulty.

        Just explain, if localtime has a different time to a fraction of a second, how come when the program interacts in a loop it wouldn't give a different time for a new line, since localtime is getting called again by this new interaction inside of the loop. That's what I can't understand.

      Yes. We all noticed that. But how many times does that piece of code get executed? It looks as tho' it's only called once, so the value of $localtime is set once but never changed.

      --
      <http://dave.org.uk>

      "The first rule of Perl club is you do not talk about Perl club."
      -- Chip Salzenberg

        How could I have it changing in every line inside of the loop?
Re^2: Localtime Updating
by Anonymous Monk on Feb 24, 2006 at 16:05 UTC
    Still doesn't work, it gives me the same lines with repeated times:
    [Fri Feb 24 10:55:45 2006.068] test_of_log.txt : Loading trans [Fri Feb 24 10:55:45 2006.068] test_of_log.txt : Loading trans [Fri Feb 24 10:55:45 2006.068] test_of_log.txt : Loading trans [Fri Feb 24 10:55:45 2006.068] test_of_log.txt : Loading trans [Fri Feb 24 10:55:45 2006.068] test_of_log.txt : Loading trans [Fri Feb 24 10:55:45 2006.068] test_of_log.txt : Loading trans [Fri Feb 24 10:55:45 2006.068] test_of_log.txt : Loading trans