use Tk; my $mw = MainWindow -> new; $mw -> title("Test Code With Serial Port and GUI"); my $btn_01=$mw->Button(-text =>"Done", -command=>sub{exit}) ->pack; my $btn_02=$mw->Button(-text=>"Serial Port", -command=>sub{$thr=threads->new(\&serial_port)}) ->pack; MainLoop;