in reply to Re^4: Threads::Shared MultiLevel Hash and the Invalid value for Shared Scalar Error
in thread Threads::Shared MultiLevel Hash and the Invalid value for Shared Scalar Error

There are many anomalies in your OP code.

For example, you have many blocks of code like this:

unless (exists $$dataref{$eid}{"ALL"}{"MatchesPeopleEn +ded"}){ my %a :shared; $$dataref{$sid}{"ALL"}{"MatchesEnded"}=\%a; }

Note that you are testing exists $$dataref{$eid}{"ALL"}{"MatchesPeopleEnded"})

But are assigning to $$dataref{$sid}{"ALL"}{"MatchesEnded"}=\%a;

That probably explains your immediate problem. However, there are further anomalies.

For example, why are you assigning references to shared hashes to a bunch of variables that you subsequently are using as integers:

$$dataref{$sid}{"ALL"}{"MatchesStarted"}++; $$dataref{$sid}{"ALL"}{"MatchesPeopleStarted"} += $tn; $$dataref{$sid}{$whichco}{"MatchesPeopleStarted"} += $tn; $$dataref{$sid}{$whichco}{"MatchesStarted"}++; $$dataref{$eid}{"ALL"}{"MatchesEnded"}++; $$dataref{$eid}{"ALL"}{"MatchesPeopleEnded"} += $tn; $$dataref{$eid}{$whichco}{"MatchesPeopleEnded"} += $tn; $$dataref{$eid}{$whichco}{"MatchesEnded"}++;

Part of your problem is that you spread your code around all over the place which means that you need to scroll up down many pages to see where a variable is declared, initialised and then used.

There is a huge chunk of code in the middle of your program that I suspect could be replace by this:

$$dataref{$sid} //= &shared({}); $$dataref{$sid}{"ALL"} //= &shared({}); $$dataref{$sid}{"ALL"}{"MatchesStarted"}++; $$dataref{$sid}{"ALL"}{"MatchesPeopleStarted"} += +$tn; $$dataref{$sid}{$whichco} //= &shared({}); $$dataref{$sid}{$whichco}{"MatchesPeopleStarted"} ++= $tn; $$dataref{$sid}{$whichco}{"MatchesStarted"}++; $$dataref{$eid} //= &shared({}); $$dataref{$eid}{"ALL"} //= &shared({}); $$dataref{$eid}{"ALL"}{"MatchesEnded"}++; $$dataref{$eid}{"ALL"}{"MatchesPeopleEnded"} += $t +n; $$dataref{$eid}{$whichco} //= &shared({}); $$dataref{$eid}{$whichco}{"MatchesPeopleEnded"} += + $tn; $$dataref{$eid}{$whichco}{"MatchesEnded"}++;

Which might improve things a little, but I have no way to test that.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
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.