%list being a hash of sockets like
%list{listName}->socketObject;
Then I use the sockets in subroutines like
sub sendToList {
send stuff to all $list{listName}->socketObjects;
...
}
Would that be okay with no memory leaks, or would it hold on to the socketObjects even after delete $list{listName} ?
Would it be the same for
http_request (
...
,sub {
send stuff to all $list{listName}->socketObjects;
});
Closure stuff seems difficult for me to grasp :(
Again thanks for your reply.
Comment on Re^2: How to avoid closures and memory leaks.
This is less an issue of closures and more an issue of you not understanding the difference between global variables (use vars) and lexical variables (my). See Coping With Scoping for a good explanation of these things.
Basically, what you declare with use vars are global variable names, and these have no issues with closures, because anyone can get at a global variable as long as they know the name.