http://qs321.pair.com?node_id=377214

beable has asked for the wisdom of the Perl Monks concerning the following question:

Is returning a list broken when using threads? I find the difference in behaviour between calling a subroutine which returns a list in a thread and calling the subroutine directly hard to understand. When calling the subroutine with a thread, I'm only getting the last element of the list back. When I call the subroutine without a thread, I get the whole list. What's going on? The code below is mostly from perlthrtut.

#!/usr/bin/perl use threads; $thr = threads->new(\&sub1); @ReturnData = $thr->join; print "Thread returned @ReturnData\n"; print "array size is: ", scalar(@ReturnData), "\n"; @ReturnData = sub1(); print "Subroutine returned @ReturnData\n"; print "array size is: ", scalar(@ReturnData), "\n"; sub sub1 { return ("Fifty-six", "foo", 23); } __END__ Output: Thread returned 23 array size is: 1 Subroutine returned Fifty-six foo 23 array size is: 3