Hash outside the sub routine: %hash = (); // for storing drift line %printable_data = (); // some data are there $terminal = new Term::Screen; $screen_height = $terminal->row; The thread subroutine: sub refresher { $terminal->at(0,0); $terminal->clreos(); foreach (keys %printable_data) { $term->puts($_); . . . if ( $curser_position >= $screen_height ) { $hash{$key} = $_; } } }