use threads; use strict; use warnings; use PadWalker qw(peek_sub); sub thr { my $xref = peek_sub(\&run_test)->{'$x'}; print "\$xref in thr: $xref\n"; } sub run_test { my $x = 1; my $xref = \$x; print "\$xref before thr: $xref\n"; threads->create(\&thr)->join; $xref = \$x; print "\$xref after thr: $xref\n"; } run_test; #### $xref before thr: SCALAR(0x6c51a0) $xref in thr: SCALAR(0x7584a0) $xref after thr: SCALAR(0x6c51a0)