Updated: Added archen's code suggestion as a comment. And then later added bbfu's code too. Plus links on monk names.
@rem = ' @echo off goto BEGINBAT # ----------------------------------------------- # # Do not run this software, it will make you die. # # ----------------------------------------------- # :BEGINBAT rem search the path if batch is not in current directory set PARGS= if not exist %0.bat set PARGS=-S perl %PARGS% %0.bat %1 set PARGS= goto ENDOFBAT :USAGE echo Print some usage info here. goto ENDOFBAT '; # Perl Script goes here. ++$|; print <<END; ******************* My Stupid eggtimer. ******************* Enter a duration in seconds. Q to quit. END while (1) { my $time = get_time(); print "Sleeping for $time seconds.\n"; foreach (1..$time) { # Comment out this print and uncomment the next print to impl +ement print "."; # archen's most excellent suggestion, # print "\b" x length(localtime), scalar(localtime); # or try bbfu's great idea: # print "\b" x length($time-$_+1), $time-$_; sleep(1); } beep(); } sub beep { my $count = shift || 10; # Ring some ASCII bells print chr(0x07)x$count; } sub get_time { my $time; do { print "\n-> "; $time = <>; chomp $time; print "\n"; exit if $time =~/^q/i; } while ($time ne $time+0); return $time; } __END__ :ENDOFBAT
TGI says moo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: An Egg(?) Timer
by archen (Pilgrim) on Oct 09, 2001 at 08:16 UTC | |
by bbfu (Curate) on Oct 10, 2001 at 01:23 UTC | |
|
Re: An Egg(?) Timer
by strfry() (Monk) on Oct 12, 2001 at 00:54 UTC |