use threads; use threads::shared; my $thr; # thread my $Rval:shared;# return value inside thread my $RTval; # return value intended to be "out in Tk code" # the following 3 lines of code would be invoked by a button press $thr=threads->new(\&sub_name); $TRval = $thr->join; print "$TRval"; # $TRval is in MainWindow Tk code sub sub_name { $Rval = `a_command_line_function`; # final code will have serial port activity }