use threads; use threads::shared; ... my $data_in:shared = 0; my $data_ret:shared = '----'; my $button_control:shared = 0; my $go_control:shared = 0; my $die_control:shared = 0; ... my $thr = threads->create( \&worker ); ...