sub timetill { # don't use prototypes local $| = 1; # will be restored on exit scope my $time = shift || return; # use "undef" to signal errors in Perl my $line = shift || " seconds until event"; # why chomp? while($time > 0) { my $prompt = sprintf "%3d $line", $time; print $prompt; sleep 1; print "\b" x length $prompt; # no need to edit the function $time--; } }
Please read Are prototypes evil? and Tom Christiansen's explanation on prototypes.
Makeshifts last the longest.
In reply to Re: Time until event
by Aristotle
in thread Time until event
by halxd2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |