in reply to Re: volatile memory?
in thread volatile memory?

I'm not intentionally using multiple threads, though the computer is dual core.

The error occurs within the loop; every so often, $array[0] contains the wrong value (yes, numeric), but always a previously used value. In tests, only about 20% of the values were wrong, the others right. And the second while loop solved the errors. I don't know how to explain that, really.

mytestfunc only reads values from the array, and does not change it.

Replies are listed 'Best First'.
Re^3: volatile memory?
by wwe (Friar) on Sep 02, 2010 at 10:10 UTC
    Hi kjcdb8er, I just set up a little test to prove the fast assignment and reassignment of values in the array:
    # 858508.pl use strict; use warnings; use 5.010; my @array_old = my @array = ( 1 .. 10e3 ); for my $i ( 0 .. $#array ) { my $buffer = $array[$i]; $array[$i] = new_value(); $array[$i] = $buffer; } if( @array_old ~~ @array ) { say "arrays are equal"; } else { say "array are different"; } sub new_value { rand(); }
    This code creates an array of consequtive numbers from 1 to 10000 and changes every number to a random value and restores the initial value. I wasn't able to reproduce your problem. I suppose the problem you are facing is located on the different code part as you showed.
Re^3: volatile memory?
by renshui (Novice) on Sep 02, 2010 at 09:29 UTC
    You can post the complete code so that others can run your code on their machine.