use threads; use threads::shared; use Thread::Queue; use Wx; my %thread_hash; share(%thread_hash); # ... # create $twit object eval { my $twit = Net::Twitter->new( { username => $username, password => $password, } ); if ( defined $twit ) { # I've tried setting it here # but it complains ... $thread_hash{'twit'} = $twit; # This works fine, and it's what I currently call # but I can't access this from the thread because # the worker thread was created way before any # of this code. $self->{twit} = $twit; } }; if ( my $err = $@ ) { return; } # ... # starting my actual thread sub StartThread { my ($self, $event) = @_; use Data::Dumper; print Dumper( %thread_hash ); $self->{queue}->enqueue('GO'); }