123456789101112131415161718
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 = <STDIN>);}