in reply to Report current results during batch process?

You can start a new thread that reads from stdin, and just share the variable $cnt to that thread,
use strict; use threads; use threads::shared; my $cnt:shared = 0; my $t = threads->new(\&get_input); while(1){ #simulate some task ++$cnt; sleep 2; } $t->join(); sub get_input{ while(1){ my $key = <>; chomp $key; if($key eq " "){ print "$cnt\n"; } } }