in reply to Quickly detecting variable writes
I'm probably missing something, but why not take a copy of $x before the loop and check if it has changed afterwards?
sub onTick { our $x; my $copyX = $x; # Initialize and associate $x with some external value foreach (@kabluther) { $x += $_->getSkookiness(); } if( $x != $copyX ) { notifyWatchers( $x ); } return $x; }
That wouldn't detect serial changes that result in no change--$x += 10; $x += -4; $x += -6;--but whether that is a problem depends upon what the watchers are watching?
|
|---|