On Thu, 8 Jul 2004 14:05:59 -0400, perl.org wrote
> It seems random - most of the time it gets one number, but just once 
> in a while it gets that number plus one.  I can't prove it (it's 
> difficult to track) but it seems like I can get the original value 
> after I've gotten the incremented value.  I will run some tests if I 
> have time.

I have not been able to reproduce this in my drastically simplified test case;
it must be a bug in my code (while I've written my share of bugs I honestly
don't see how this could be one), a side effect of more complex interaction or
some other issue.

use strict;

my %data = getDateTime();
my $orig = $data{sec};
print 'Original seconds : ', $orig, ${/};

for( my $i = 0 ; ${i} < 5000000 ; $i++ )
{
  %data = getDateTime();
  my $sec = $data{sec};

  if ( $sec != $orig )
  {
    print $sec, ' does not match original value ', $orig, ' : iteration : ',
${i}, $/;
  }
}

sub getDateTime
{
  ( $data{sec}, $data{min}, $data{hour}, $data{day}, $data{mon}, $data{year},
$data{wday}, $data{yday}, $data{isdst} ) = localtime( $^T );
  $data{year} += 1900;
  $data{mon}++;
  return( %{data} );
}

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to