pseudo code or something just to illustrate what the code is doing use strict; my %hs1; #... $| =1; while(1){ chomp(<>); do something to fill %hs1 if ($_=~/X/); sleep 5; %hs1 = (); } #### use strict; use threads; use threads::shared; share(my $var); #some other hashes not shared; my %hs1; #... $| =1; while(1){ chomp(<>); _progress(); do something to fill %hs1 if ($_=~/X/); _stop(); sleep 5; %hs1 = (); } sub _progress { threads->new(\&_status)->detach; } sub _status { my $count = 0; while($var){ my $bar; if ($count == 10){ $bar = '' ; $count = 0; } $bar .= '>' print "\r$bar"; $count++; sleep 1; } } _stop { $var = 0; }