#!/usr/bin/perl use warnings; use strict; use threads; use threads::shared; # join() does three things: it waits for a thread to exit, # cleans up after it, and returns any data the thread may # have produced. my $die : shared = 0; my $thr = threads->new(\&sub1); #hold for key input <>; $die=1; my $return = $thr->join; print "Thread returned @$return\n"; #hold for key input <>; ########################################################## sub sub1 { my @values = ('1',2, 'ten'); print "@values\n"; while(1){ sleep 1; if($die){return \@values } } return \@values; }