Day 8: Stopwatch (App::stopw)

About the series: perlancar's 2014 Advent Calendar: Introduction to a selection of 24 modules which I published in 2014. Table of contents.

Okay, this post couldn't be simpler. stopw (from the App-stopw distribution) is a very simple CLI program. When run, it displays a running stopwatch, upon which you can press Spacebar to let it move down one line (so you can see/note the time you pressed the Space), or Enter to pause/resume, Z to reset back to 0, or Q to quit. I'm almost shameful that it took my Perl code more than 100 lines to accomplish this (I think the teenager me from the 1980's would surely have been able to whip up this task in about 20 lines of BASICA/GW-BASIC).

I now try hard to remember why I needed this in the first place, but can't recall. Probably to time some subtitle, or a song that I listen on the radio, or to exercise holding my breath, or exercise my reflex. But probably not.

Anyways, there is an existing CLI stopwatch on CPAN before I wrote this: App::Stopwatch (which includes the stopwatch utility), written by BESSARABV. However, it doesn't show subsecond precision, and does not allow for many controls like pausing/reseting. Plus, the name clashes with the Debian package of the same name.

Leave a comment

About perlancar

user-pic #perl #indonesia