I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2010-02-12 10:41:50.735554-08 by tetley
Shared variables across require?
Hi, Are there any known issues with sharing thread variables across "require"'d files? I will do this:


my %tid : shared;

sub start_th {
$tid{hello} = 99999;
require "child.pl";
...
}

where child.pl somewhere contains:
$tid{hello} = 11111;

If I make %tid shared, the value of $tid{hello} is 99999, even though child.pl is supposed to be setting it to 11111 in the same thread. If I set $tid{hello} to 11111 in the parent.pl (without the require), it correctly sets to 11111. If I don't share %tid at all, it correctly returns 1111 1 even with the require, but now I can't access the value from outside that thread. I tried putting/not putting the require in a BEGIN, everything. thanks!
Direct Responses: 12373 | Write a response