Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Quickly detecting variable writes

by BrowserUk (Patriarch)
on Jan 05, 2007 at 02:41 UTC ( [id://593058]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://593058]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-03-29 01:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found