in reply to overwritting print in same line
I changed your "sleep .05" to "select undef, undef, undef, 0.05" because the normal Perl sleep function works in seconds, so "sleep .05" is the same as "sleep 0". See sleep for an explanation and other alternatives. I also added "$|=1" to avoid having the output getting buffered and not displaying anything for long periods of time; see $OUTPUT_AUTOFLUSH.use warnings; use strict; my $spin; while (1) { print substr( "-/|\\", $spin++ % 4, 1 ), "\b"; $| = 1; select undef, undef, undef, 0.05; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: overwritting print in same line
by Anonymous Monk on Nov 14, 2011 at 07:22 UTC | |
|
Re^2: overwritting print in same line
by raybies (Chaplain) on Nov 14, 2011 at 13:39 UTC |