Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^8: PSGI, Plack, Twiggy, AnyEvent and SockJS... I need help

by xtpu2 (Acolyte)
on Apr 09, 2014 at 18:56 UTC ( #1081712=note: print w/ replies, xml ) Need Help??


in reply to Re^7: PSGI, Plack, Twiggy, AnyEvent and SockJS... I need help
in thread PSGI, Plack, Twiggy, AnyEvent and SockJS... I need help

Interesting! I didn't quite understand what you meant about "mentioning" the variable first time around. Just now, I replaced undef $w if (0); with $w; and other than a warning about Useless use of private variable in void context, it worked fine. Is there a best practice for how to "mention" variables in this kind of context?

For now, off to read about closures.

Edited to add after reading about closures: So basically, the reason I want to mention the variable $w within the callback subroutine is so that the variable becomes part of the lexical scope of the closure? I'm not sure if that's the correct terminology... But basically, unless the variable is somehow being used within the subroutine, it will be destroyed once all the callbacks and event handlers have been set up?


Comment on Re^8: PSGI, Plack, Twiggy, AnyEvent and SockJS... I need help
Re^9: PSGI, Plack, Twiggy, AnyEvent and SockJS... I need help
by Corion (Pope) on Apr 09, 2014 at 20:04 UTC

    Exactly - once the value goes out of scope, it gets released. You want to prevent this and release all references to the value when you want to stop the timer (if ever).

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2014-12-28 14:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (181 votes), past polls