use forks; use forks::shared; my $variable : shared; $variable = "init"; my $thread = threads->new (sub { while() { sleep 1; print STDERR "\r", $variable; } }); while() { print STDERR " "x40, "Enter new value for \$variable: "; chomp($variable = ); }