As for the suggested code snippet, I still end up with the thread having it's own private copy of the $self->{var}.
I can see each process having its own copy of $self->{var}, but what about ${$self->{var}} ?? They should be referring to the same shared data, no? | [reply] |
Gee... Thanks. =)
When referring to them as ${$self->{var}] it DOES work. The problem is now officially solved. Now, would you please explain to me what you did, because I am feeling abit lost here. =)
And... This doesn't mean that the data is shared between all instances off the class, right? | [reply] |
This doesn't mean that the data is shared between all instances off the class, right?
That I couldn't tell you for sure. My guess is that the data IS shared in a way across all threads, but since the reader is only looking at the one instance passed to it, that should be the only data that matters between those two threads, and another instance will generate a separate shared variable in a separate object and so the reader for that object will be looking at different data.
BTW, $hash{key} = \$var stores a reference to the scalar in the hash, and normally to dereference a scalar reference you put a '$' in front of it, but since its in a hash you need to wrap the whole thing with curlies. E.g.
my $var = 1;
my $ref = \$var;
my %hash = ( key => \$var );
# All print '1'
print $var;
print $$ref;
print ${$hash{key}};
You could probably look through perlref and perlreftut and other reference tutorials...search this site..(sorry don't have any handy). | [reply] [d/l] [select] |