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 11:21:42.320216-08 by jdhedden in response to 12371
Re: Shared variables across require?
First of all, you need to 'use strict;' and 'use warnings;'. That would have told you that there was an issue with child.pl:

Global symbol "%tid" requires explicit package name at child.pl line 4.
Compilation failed in require at ./parent.pl line 10.


When you want to influence variables across 'require' you need to declare them as 'our'; not 'my'. The following works:
#!/usr/bin/perl # parent.pl use strict; use warnings; use threads; use threads::shared; our %tid : shared; sub start_th { $tid{hello} = 99999; print($tid{hello}, "\n"); require "child.pl"; print($tid{hello}, "\n"); } start_th;
use strict; use warnings; use threads; use threads::shared; our %tid : shared; $tid{hello} = 11111; 1;
Direct Responses: 12374 | Write a response