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?


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."