while(defined($_ = $term->readline($prompt))) { [case statement to parse command] } #### while (not time to quit) { [see if there is keyboard stuff to process] [process any timer based stuff] [go back to sleep] }