#!/usr/bin/env perl use strict; use threads; use Thread::Queue; my $q=Thread::Queue->new; my $thr=async { my $progref; sub ch { print "In ch \$progref=$progref\n"; #progref is still undefined (why?) $$progref=90; } $progref=$q->dequeue; #This seems to create a local $progref, but it shouldn't! print "In main part of thread \$progref=$progref\n"; $$progref=30; #This is applied ch(); #This is ignored }; my $prog :shared; $q->enqueue(\$prog); sleep 2; print "$prog\n"; #Prints 30, not 90 $q->end; $thr->join;