sub slow_print { my $subscript = shift; my $para = $paras[ $subscript ]; if ( $wrapping ) { $para = &rewrap( $para ); } # include the filename/line number index in the paragraph instead # of printing it separately, so we don't have to duplicate the # sleeping/keypress-handling logic below. if ( $print_filenames or $debug ) { $para = $indices[ $subscript ] . $para; } my @lines = split /\n/, $para; foreach ( @lines ) { print $_ . "\n"; # If the user presses a key before the pause time for # the current line has passed, we don't necessarily skip # to the next line with no further pause. my $start = time; my $remaining_wait = $pause_len * length $_; while ( time < ( $start + $remaining_wait ) ) { my $key = ReadKey( $remaining_wait ); if ( defined $key ) { &handle_keystroke( $key ); } # the $pause_len might have been changed by user's keypress $remaining_wait = ($pause_len * length $_) - (time - $start); } } print "\n\n"; }