I just slapped together this timer program, and I thought I'd share it. It could be useful for all sorts of lovely things like cooking eggs just right, playing boggle, or timing naps at work. I use it for timing meditation breaks. I've wrapped in a batch file, people with real operating systems can remove the taint as an exercise.

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


In reply to An Egg(?) Timer by TGI

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.