use threads (); my $foo; threads->new( sub {print "thread: coderef = ".\$foo."\n"} )->join; print " main: coderef = ".\$foo."\n";